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" |
|
dcheng
2012/08/20 19:10:01
#include "base/memory/scoped_ptr.h"
Pete Williamson
2012/08/20 20:53:05
Done.
| |
| 12 #include "chrome/browser/extensions/api/push_messaging/invalidation_handler_obse rver.h" | 12 #include "chrome/browser/extensions/api/push_messaging/invalidation_handler_obse rver.h" |
| 13 #include "chrome/browser/extensions/api/push_messaging/obfuscated_gaia_id_fetche r.h" | |
| 14 #include "chrome/browser/extensions/extension_function.h" | |
| 15 #include "chrome/common/net/gaia/google_service_auth_error.h" | |
| 13 | 16 |
| 14 class Profile; | 17 class Profile; |
| 15 | 18 |
| 16 namespace extensions { | 19 namespace extensions { |
| 17 | 20 |
| 18 // Observes a single InvalidationHandler and generates onMessage events. | 21 // Observes a single InvalidationHandler and generates onMessage events. |
| 19 class PushMessagingEventRouter : public InvalidationHandlerObserver { | 22 class PushMessagingEventRouter : public InvalidationHandlerObserver { |
| 20 public: | 23 public: |
| 21 explicit PushMessagingEventRouter(Profile* profile); | 24 explicit PushMessagingEventRouter(Profile* profile); |
| 22 virtual ~PushMessagingEventRouter(); | 25 virtual ~PushMessagingEventRouter(); |
| 23 | 26 |
| 24 void Init(); | 27 void Init(); |
| 25 | 28 |
| 26 private: | 29 private: |
| 27 FRIEND_TEST_ALL_PREFIXES(PushMessagingApiTest, EventDispatch); | 30 FRIEND_TEST_ALL_PREFIXES(PushMessagingApiTest, EventDispatch); |
| 28 | 31 |
| 29 // InvalidationHandlerObserver implementation. | 32 // InvalidationHandlerObserver implementation. |
| 30 virtual void OnMessage(const std::string& extension_id, | 33 virtual void OnMessage(const std::string& extension_id, |
| 31 int subchannel, | 34 int subchannel, |
| 32 const std::string& payload) OVERRIDE; | 35 const std::string& payload) OVERRIDE; |
| 33 | 36 |
| 34 Profile* profile_; | 37 Profile* profile_; |
| 35 | 38 |
| 36 DISALLOW_COPY_AND_ASSIGN(PushMessagingEventRouter); | 39 DISALLOW_COPY_AND_ASSIGN(PushMessagingEventRouter); |
| 37 }; | 40 }; |
| 38 | 41 |
| 42 class PushMessagingGetChannelIdFunction | |
| 43 : public AsyncExtensionFunction, public ObfuscatedGaiaIdFetcher::Delegate{ | |
|
dcheng
2012/08/20 19:10:01
Indent two spaces. Missing space before {
Pete Williamson
2012/08/20 20:53:05
Added spaces
| |
| 44 public: | |
| 45 PushMessagingGetChannelIdFunction(); | |
| 46 | |
| 47 protected: | |
| 48 virtual ~PushMessagingGetChannelIdFunction(); | |
| 49 | |
| 50 // ExtensionFunction: | |
| 51 virtual bool RunImpl() OVERRIDE; | |
| 52 DECLARE_EXTENSION_FUNCTION_NAME("experimental.pushMessaging.getChannelId"); | |
| 53 | |
| 54 private: | |
| 55 void GetChannelIdOnIOThread(); | |
| 56 void RespondOnUIThread(const std::string& gaiaId, const long status); | |
| 57 void StartGaiaIdFetch(); | |
| 58 virtual void OnObfuscatedGaiaIdFetchSuccess(const std::string& gaia_id) | |
|
dcheng
2012/08/20 19:10:01
I'd add a comment here:
// ObfuscatedGiaiaIdFetche
Pete Williamson
2012/08/20 20:53:05
Done.
| |
| 59 OVERRIDE; | |
| 60 virtual void OnObfuscatedGaiaIdFetchFailure( | |
| 61 const GoogleServiceAuthError& error) OVERRIDE; | |
| 62 scoped_ptr<ObfuscatedGaiaIdFetcher> fetcher_; | |
| 63 | |
| 64 DISALLOW_COPY_AND_ASSIGN(PushMessagingGetChannelIdFunction); | |
| 65 }; | |
| 66 | |
| 39 } // namespace extension | 67 } // namespace extension |
| 40 | 68 |
| 41 #endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__ | 69 #endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__ |
| OLD | NEW |