OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_GCM_APP_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_GCM_APP_HANDLER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_GCM_APP_HANDLER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_GCM_APP_HANDLER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 virtual void ShutdownHandler() OVERRIDE; | 49 virtual void ShutdownHandler() OVERRIDE; |
50 virtual void OnMessage( | 50 virtual void OnMessage( |
51 const std::string& app_id, | 51 const std::string& app_id, |
52 const gcm::GCMClient::IncomingMessage& message) OVERRIDE; | 52 const gcm::GCMClient::IncomingMessage& message) OVERRIDE; |
53 virtual void OnMessagesDeleted(const std::string& app_id) OVERRIDE; | 53 virtual void OnMessagesDeleted(const std::string& app_id) OVERRIDE; |
54 virtual void OnSendError( | 54 virtual void OnSendError( |
55 const std::string& app_id, | 55 const std::string& app_id, |
56 const gcm::GCMClient::SendErrorDetails& send_error_details) OVERRIDE; | 56 const gcm::GCMClient::SendErrorDetails& send_error_details) OVERRIDE; |
57 | 57 |
58 protected: | 58 protected: |
| 59 // Could be overridden by testing purpose. |
59 virtual void OnUnregisterCompleted(const std::string& app_id, | 60 virtual void OnUnregisterCompleted(const std::string& app_id, |
60 gcm::GCMClient::Result result); | 61 gcm::GCMClient::Result result); |
| 62 virtual void AddAppHandler(const std::string& app_id); |
| 63 virtual void RemoveAppHandler(const std::string& app_id); |
61 | 64 |
62 private: | 65 gcm::GCMDriver* GetGCMDriver() const; |
| 66 |
| 67 private: |
63 friend class BrowserContextKeyedAPIFactory<ExtensionGCMAppHandler>; | 68 friend class BrowserContextKeyedAPIFactory<ExtensionGCMAppHandler>; |
64 | 69 |
65 // ExtensionRegistryObserver implementation. | 70 // ExtensionRegistryObserver implementation. |
66 virtual void OnExtensionLoaded(content::BrowserContext* browser_context, | 71 virtual void OnExtensionLoaded(content::BrowserContext* browser_context, |
67 const Extension* extension) OVERRIDE; | 72 const Extension* extension) OVERRIDE; |
68 virtual void OnExtensionUnloaded( | 73 virtual void OnExtensionUnloaded( |
69 content::BrowserContext* browser_context, | 74 content::BrowserContext* browser_context, |
70 const Extension* extension, | 75 const Extension* extension, |
71 UnloadedExtensionInfo::Reason reason) OVERRIDE; | 76 UnloadedExtensionInfo::Reason reason) OVERRIDE; |
72 virtual void OnExtensionUninstalled(content::BrowserContext* browser_context, | 77 virtual void OnExtensionUninstalled(content::BrowserContext* browser_context, |
73 const Extension* extension) OVERRIDE; | 78 const Extension* extension) OVERRIDE; |
74 | 79 |
75 gcm::GCMDriver* GetGCMDriver() const; | 80 void AddDummyAppHandler(); |
| 81 void RemoveDummyAppHandler(); |
76 | 82 |
77 // BrowserContextKeyedAPI implementation. | 83 // BrowserContextKeyedAPI implementation. |
78 static const char* service_name() { return "ExtensionGCMAppHandler"; } | 84 static const char* service_name() { return "ExtensionGCMAppHandler"; } |
79 static const bool kServiceIsNULLWhileTesting = true; | 85 static const bool kServiceIsNULLWhileTesting = true; |
80 | 86 |
81 Profile* profile_; | 87 Profile* profile_; |
82 | 88 |
83 // Listen to extension load, unloaded notifications. | 89 // Listen to extension load, unloaded notifications. |
84 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | 90 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
85 extension_registry_observer_; | 91 extension_registry_observer_; |
86 | 92 |
87 #if !defined(OS_ANDROID) | 93 #if !defined(OS_ANDROID) |
88 scoped_ptr<extensions::GcmJsEventRouter> js_event_router_; | 94 scoped_ptr<extensions::GcmJsEventRouter> js_event_router_; |
89 #endif | 95 #endif |
90 | 96 |
91 base::WeakPtrFactory<ExtensionGCMAppHandler> weak_factory_; | 97 base::WeakPtrFactory<ExtensionGCMAppHandler> weak_factory_; |
92 | 98 |
93 DISALLOW_COPY_AND_ASSIGN(ExtensionGCMAppHandler); | 99 DISALLOW_COPY_AND_ASSIGN(ExtensionGCMAppHandler); |
94 }; | 100 }; |
95 | 101 |
96 } // namespace extensions | 102 } // namespace extensions |
97 | 103 |
98 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_GCM_APP_HANDLER_H_ | 104 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_GCM_APP_HANDLER_H_ |
OLD | NEW |