Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__ | 6 #define CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/memory/scoped_ptr.h" | |
| 12 #include "chrome/browser/extensions/api/push_messaging/invalidation_handler_obse rver.h" | 13 #include "chrome/browser/extensions/api/push_messaging/invalidation_handler_obse rver.h" |
| 14 #include "chrome/browser/extensions/api/push_messaging/obfuscated_gaia_id_fetche r.h" | |
| 15 #include "chrome/browser/extensions/extension_function.h" | |
| 16 #include "chrome/common/net/gaia/google_service_auth_error.h" | |
| 13 | 17 |
| 14 class Profile; | 18 class Profile; |
| 15 | 19 |
| 16 namespace extensions { | 20 namespace extensions { |
| 17 | 21 |
| 18 // Observes a single InvalidationHandler and generates onMessage events. | 22 // Observes a single InvalidationHandler and generates onMessage events. |
| 19 class PushMessagingEventRouter : public InvalidationHandlerObserver { | 23 class PushMessagingEventRouter : public InvalidationHandlerObserver { |
| 20 public: | 24 public: |
| 21 explicit PushMessagingEventRouter(Profile* profile); | 25 explicit PushMessagingEventRouter(Profile* profile); |
| 22 virtual ~PushMessagingEventRouter(); | 26 virtual ~PushMessagingEventRouter(); |
| 23 | 27 |
| 24 void Init(); | 28 void Init(); |
| 25 | 29 |
| 26 private: | 30 private: |
| 27 FRIEND_TEST_ALL_PREFIXES(PushMessagingApiTest, EventDispatch); | 31 FRIEND_TEST_ALL_PREFIXES(PushMessagingApiTest, EventDispatch); |
| 28 | 32 |
| 29 // InvalidationHandlerObserver implementation. | 33 // InvalidationHandlerObserver implementation. |
| 30 virtual void OnMessage(const std::string& extension_id, | 34 virtual void OnMessage(const std::string& extension_id, |
| 31 int subchannel, | 35 int subchannel, |
| 32 const std::string& payload) OVERRIDE; | 36 const std::string& payload) OVERRIDE; |
| 33 | 37 |
| 34 Profile* profile_; | 38 Profile* profile_; |
| 35 | 39 |
| 36 DISALLOW_COPY_AND_ASSIGN(PushMessagingEventRouter); | 40 DISALLOW_COPY_AND_ASSIGN(PushMessagingEventRouter); |
| 37 }; | 41 }; |
| 38 | 42 |
| 43 class PushMessagingGetChannelIdFunction | |
| 44 : public AsyncExtensionFunction, public ObfuscatedGaiaIdFetcher::Delegate { | |
| 45 public: | |
| 46 PushMessagingGetChannelIdFunction(); | |
| 47 | |
| 48 protected: | |
| 49 virtual ~PushMessagingGetChannelIdFunction(); | |
| 50 | |
| 51 // ExtensionFunction: | |
| 52 virtual bool RunImpl() OVERRIDE; | |
| 53 DECLARE_EXTENSION_FUNCTION_NAME("experimental.pushMessaging.getChannelId"); | |
| 54 | |
| 55 private: | |
| 56 void GetChannelIdOnIOThread(); | |
|
Munjal (Google)
2012/08/20 21:16:22
You are not using this method anymore.
Pete Williamson
2012/08/20 22:26:45
Done.
| |
| 57 void Respond(const std::string& gaiaId, const long status); | |
|
Munjal (Google)
2012/08/20 21:16:22
Nit: May be name "ReportResult" to be consistent w
| |
| 58 // ObfuscatedGiaiaIdFetcher::Delegate implementation. | |
| 59 virtual void OnObfuscatedGaiaIdFetchSuccess(const std::string& gaia_id) | |
| 60 OVERRIDE; | |
| 61 virtual void OnObfuscatedGaiaIdFetchFailure( | |
| 62 const GoogleServiceAuthError& error) OVERRIDE; | |
| 63 scoped_ptr<ObfuscatedGaiaIdFetcher> fetcher_; | |
| 64 | |
| 65 DISALLOW_COPY_AND_ASSIGN(PushMessagingGetChannelIdFunction); | |
| 66 }; | |
| 67 | |
| 39 } // namespace extension | 68 } // namespace extension |
| 40 | 69 |
| 41 #endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__ | 70 #endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__ |
| OLD | NEW |