1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef EXTENSIONS_BROWSER_EXTENSION_HOST_OBSERVER_H_
6 #define EXTENSIONS_BROWSER_EXTENSION_HOST_OBSERVER_H_
7 
8 #include <stdint.h>
9 
10 #include <string>
11 
12 namespace extensions {
13 class ExtensionHost;
14 
15 class ExtensionHostObserver {
16  public:
~ExtensionHostObserver()17   virtual ~ExtensionHostObserver() {}
18 
19   // TODO(kalman): Why do these all return const ExtensionHosts? It seems
20   // perfectly reasonable for an Observer implementation to mutate any
21   // ExtensionHost it's given.
22 
23   // Called when an ExtensionHost is destroyed.
OnExtensionHostDestroyed(ExtensionHost * host)24   virtual void OnExtensionHostDestroyed(ExtensionHost* host) {}
25 
26   // Called when the ExtensionHost has finished the first load.
OnExtensionHostDidStopFirstLoad(const ExtensionHost * host)27   virtual void OnExtensionHostDidStopFirstLoad(const ExtensionHost* host) {}
28 
29   // Called when a message has been disptached to the event page corresponding
30   // to |host|.
OnBackgroundEventDispatched(const ExtensionHost * host,const std::string & event_name,int event_id)31   virtual void OnBackgroundEventDispatched(const ExtensionHost* host,
32                                            const std::string& event_name,
33                                            int event_id) {}
34 
35   // Called when a previously dispatched message has been acked by the
36   // event page for |host|.
OnBackgroundEventAcked(const ExtensionHost * host,int event_id)37   virtual void OnBackgroundEventAcked(const ExtensionHost* host, int event_id) {
38   }
39 
40   // Called when the extension associated with |host| starts a new network
41   // request.
OnNetworkRequestStarted(const ExtensionHost * host,uint64_t request_id)42   virtual void OnNetworkRequestStarted(const ExtensionHost* host,
43                                        uint64_t request_id) {}
44 
45   // Called when the network request with |request_id| is done.
OnNetworkRequestDone(const ExtensionHost * host,uint64_t request_id)46   virtual void OnNetworkRequestDone(const ExtensionHost* host,
47                                     uint64_t request_id) {}
48 };
49 
50 }  // namespace extensions
51 
52 #endif /* EXTENSIONS_BROWSER_EXTENSION_HOST_OBSERVER_H_ */
53