diff options
author | jianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-14 20:47:18 +0000 |
---|---|---|
committer | jianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-14 20:47:18 +0000 |
commit | 446f73c264c493eac63b6c7c5d8ebcc1e2c544c4 (patch) | |
tree | 51a8c8f1401717de3fe67f66148a9c51dc08850d /chrome | |
parent | d0499e03c209ce7a179a2ba453742eca9da8ede6 (diff) | |
download | chromium_src-446f73c264c493eac63b6c7c5d8ebcc1e2c544c4.zip chromium_src-446f73c264c493eac63b6c7c5d8ebcc1e2c544c4.tar.gz chromium_src-446f73c264c493eac63b6c7c5d8ebcc1e2c544c4.tar.bz2 |
Componentize GCM Part 1: create GCM component and move some files over
BUG=356716
TEST=existing tests
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=270226
R=blundell@chromium.org, fgorski@chromium.org, jhawkins@chromium.org, kalman@chromium.org, pavely@chromium.org, zea@chromium.org
Review URL: https://codereview.chromium.org/261853012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@270470 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
20 files changed, 34 insertions, 187 deletions
diff --git a/chrome/browser/DEPS b/chrome/browser/DEPS index 86d6aba..e764055 100644 --- a/chrome/browser/DEPS +++ b/chrome/browser/DEPS @@ -23,6 +23,7 @@ include_rules = [ "+components/domain_reliability", "+components/favicon_base", "+components/feedback", + "+components/gcm_driver", "+components/google", "+components/infobars", "+components/keyed_service", diff --git a/chrome/browser/extensions/api/gcm/gcm_apitest.cc b/chrome/browser/extensions/api/gcm/gcm_apitest.cc index b93060a..70212ab 100644 --- a/chrome/browser/extensions/api/gcm/gcm_apitest.cc +++ b/chrome/browser/extensions/api/gcm/gcm_apitest.cc @@ -9,11 +9,11 @@ #include "chrome/browser/extensions/extension_gcm_app_handler.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/services/gcm/fake_gcm_profile_service.h" -#include "chrome/browser/services/gcm/gcm_client_factory.h" #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/ui_test_utils.h" +#include "components/gcm_driver/gcm_client_factory.h" namespace { diff --git a/chrome/browser/extensions/extension_gcm_app_handler.h b/chrome/browser/extensions/extension_gcm_app_handler.h index 9a7298d..7b1f0da 100644 --- a/chrome/browser/extensions/extension_gcm_app_handler.h +++ b/chrome/browser/extensions/extension_gcm_app_handler.h @@ -12,7 +12,7 @@ #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/scoped_observer.h" -#include "chrome/browser/services/gcm/gcm_app_handler.h" +#include "components/gcm_driver/gcm_app_handler.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" #include "extensions/browser/browser_context_keyed_api_factory.h" diff --git a/chrome/browser/extensions/extension_gcm_app_handler_unittest.cc b/chrome/browser/extensions/extension_gcm_app_handler_unittest.cc index 8e9f3cc..eaa72b1 100644 --- a/chrome/browser/extensions/extension_gcm_app_handler_unittest.cc +++ b/chrome/browser/extensions/extension_gcm_app_handler_unittest.cc @@ -22,13 +22,13 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/services/gcm/fake_gcm_client_factory.h" #include "chrome/browser/services/gcm/fake_signin_manager.h" -#include "chrome/browser/services/gcm/gcm_client_factory.h" #include "chrome/browser/services/gcm/gcm_client_mock.h" #include "chrome/browser/services/gcm/gcm_profile_service.h" #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" #include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/testing_profile.h" +#include "components/gcm_driver/gcm_client_factory.h" #include "components/keyed_service/core/keyed_service.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_thread.h" diff --git a/chrome/browser/invalidation/gcm_invalidation_bridge.h b/chrome/browser/invalidation/gcm_invalidation_bridge.h index a9d781e..b88449f 100644 --- a/chrome/browser/invalidation/gcm_invalidation_bridge.h +++ b/chrome/browser/invalidation/gcm_invalidation_bridge.h @@ -9,7 +9,7 @@ #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/threading/non_thread_safe.h" -#include "chrome/browser/services/gcm/gcm_app_handler.h" +#include "components/gcm_driver/gcm_app_handler.h" #include "google_apis/gaia/oauth2_token_service.h" #include "google_apis/gcm/gcm_client.h" #include "sync/notifier/gcm_network_channel_delegate.h" diff --git a/chrome/browser/services/gcm/default_gcm_app_handler.cc b/chrome/browser/services/gcm/default_gcm_app_handler.cc deleted file mode 100644 index 7b14409..0000000 --- a/chrome/browser/services/gcm/default_gcm_app_handler.cc +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/services/gcm/default_gcm_app_handler.h" - -#include "base/logging.h" - -namespace gcm { - -DefaultGCMAppHandler::DefaultGCMAppHandler() { -} - -DefaultGCMAppHandler::~DefaultGCMAppHandler() { -} - -void DefaultGCMAppHandler::ShutdownHandler() { - // Nothing to do. -} - -void DefaultGCMAppHandler::OnMessage( - const std::string& app_id, - const GCMClient::IncomingMessage& message) { - LOG(ERROR) << "No app handler is found to route message for " << app_id; -} - -void DefaultGCMAppHandler::OnMessagesDeleted(const std::string& app_id) { - LOG(ERROR) << "No app handler is found to route deleted message for " - << app_id; -} - -void DefaultGCMAppHandler::OnSendError( - const std::string& app_id, - const GCMClient::SendErrorDetails& send_error_details) { - LOG(ERROR) << "No app handler is found to route send error message for " - << app_id; -} - -} // namespace gcm diff --git a/chrome/browser/services/gcm/default_gcm_app_handler.h b/chrome/browser/services/gcm/default_gcm_app_handler.h deleted file mode 100644 index dcec5598..0000000 --- a/chrome/browser/services/gcm/default_gcm_app_handler.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_SERVICES_GCM_DEFAULT_GCM_APP_HANDLER_H_ -#define CHROME_BROWSER_SERVICES_GCM_DEFAULT_GCM_APP_HANDLER_H_ - -#include "base/compiler_specific.h" -#include "chrome/browser/services/gcm/gcm_app_handler.h" - -namespace gcm { - -// The default app handler that is triggered when there is no registered app -// handler for an application id. -class DefaultGCMAppHandler : public GCMAppHandler { - public: - DefaultGCMAppHandler(); - virtual ~DefaultGCMAppHandler(); - - // Overridden from GCMAppHandler: - virtual void ShutdownHandler() OVERRIDE; - virtual void OnMessage(const std::string& app_id, - const GCMClient::IncomingMessage& message) OVERRIDE; - virtual void OnMessagesDeleted(const std::string& app_id) OVERRIDE; - virtual void OnSendError( - const std::string& app_id, - const GCMClient::SendErrorDetails& send_error_details) OVERRIDE; - - private: - DISALLOW_COPY_AND_ASSIGN(DefaultGCMAppHandler); -}; - -} // namespace gcm - -#endif // CHROME_BROWSER_SERVICES_GCM_DEFAULT_GCM_APP_HANDLER_H_ diff --git a/chrome/browser/services/gcm/fake_gcm_client_factory.h b/chrome/browser/services/gcm/fake_gcm_client_factory.h index 11fdf65..9a9c311 100644 --- a/chrome/browser/services/gcm/fake_gcm_client_factory.h +++ b/chrome/browser/services/gcm/fake_gcm_client_factory.h @@ -7,8 +7,8 @@ #include "base/compiler_specific.h" #include "base/macros.h" -#include "chrome/browser/services/gcm/gcm_client_factory.h" #include "chrome/browser/services/gcm/gcm_client_mock.h" +#include "components/gcm_driver/gcm_client_factory.h" namespace gcm { diff --git a/chrome/browser/services/gcm/gcm_app_handler.h b/chrome/browser/services/gcm/gcm_app_handler.h index e53a25b..6777c68 100644 --- a/chrome/browser/services/gcm/gcm_app_handler.h +++ b/chrome/browser/services/gcm/gcm_app_handler.h @@ -1,42 +1,12 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_SERVICES_GCM_GCM_APP_HANDLER_H_ -#define CHROME_BROWSER_SERVICES_GCM_GCM_APP_HANDLER_H_ - -#include <string> - -#include "base/basictypes.h" -#include "google_apis/gcm/gcm_client.h" - -namespace gcm { - -// Defines the interface to provide handling and event routing logic for a given -// app. -class GCMAppHandler { - public: - GCMAppHandler() {} - virtual ~GCMAppHandler() {} - - // Called to do all the cleanup when GCM is shutting down. - // In the case that multiple apps share the same app handler, it should be - // make safe for ShutdownHandler to be called multiple times. - virtual void ShutdownHandler() = 0; - - // Called when a GCM message has been received. - virtual void OnMessage(const std::string& app_id, - const GCMClient::IncomingMessage& message) = 0; - - // Called when some GCM messages have been deleted from the server. - virtual void OnMessagesDeleted(const std::string& app_id) = 0; - - // Called when a GCM message failed to be delivered. - virtual void OnSendError( - const std::string& app_id, - const GCMClient::SendErrorDetails& send_error_details) = 0; -}; - -} // namespace gcm - -#endif // CHROME_BROWSER_SERVICES_GCM_GCM_APP_HANDLER_H_ +// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_SERVICES_GCM_GCM_APP_HANDLER_H_
+#define CHROME_BROWSER_SERVICES_GCM_GCM_APP_HANDLER_H_
+
+// Temporary workaround to make code depends on gcm_app_handler in old location
+// build.
+#include "components/gcm_driver/gcm_app_handler.h"
+
+#endif // CHROME_BROWSER_SERVICES_GCM_GCM_APP_HANDLER_H_
diff --git a/chrome/browser/services/gcm/gcm_client_factory.cc b/chrome/browser/services/gcm/gcm_client_factory.cc deleted file mode 100644 index 053b01c..0000000 --- a/chrome/browser/services/gcm/gcm_client_factory.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/services/gcm/gcm_client_factory.h" - -#include "google_apis/gcm/gcm_client_impl.h" - -namespace gcm { - -scoped_ptr<GCMClient> GCMClientFactory::BuildInstance() { - return scoped_ptr<GCMClient>(new GCMClientImpl( - make_scoped_ptr<GCMInternalsBuilder>(new GCMInternalsBuilder()))); -} - -GCMClientFactory::GCMClientFactory() { -} - -GCMClientFactory::~GCMClientFactory() { -} - -} // namespace gcm diff --git a/chrome/browser/services/gcm/gcm_client_factory.h b/chrome/browser/services/gcm/gcm_client_factory.h deleted file mode 100644 index 9112399..0000000 --- a/chrome/browser/services/gcm/gcm_client_factory.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_SERVICES_GCM_GCM_CLIENT_FACTORY_H_ -#define CHROME_BROWSER_SERVICES_GCM_GCM_CLIENT_FACTORY_H_ - -#include "base/macros.h" -#include "base/memory/scoped_ptr.h" - -namespace gcm { - -class GCMClient; - -class GCMClientFactory { - public: - GCMClientFactory(); - virtual ~GCMClientFactory(); - - // Creates a new instance of GCMClient. The testing code could override this - // to provide a mocked instance. - virtual scoped_ptr<GCMClient> BuildInstance(); - - private: - DISALLOW_COPY_AND_ASSIGN(GCMClientFactory); -}; - -} // namespace gcm - -#endif // CHROME_BROWSER_SERVICES_GCM_GCM_CLIENT_FACTORY_H_ diff --git a/chrome/browser/services/gcm/gcm_client_mock.cc b/chrome/browser/services/gcm/gcm_client_mock.cc index 96c8ffe..5ed3d90 100644 --- a/chrome/browser/services/gcm/gcm_client_mock.cc +++ b/chrome/browser/services/gcm/gcm_client_mock.cc @@ -10,6 +10,7 @@ #include "base/sys_byteorder.h" #include "base/time/time.h" #include "content/public/browser/browser_thread.h" +#include "google_apis/gcm/base/encryptor.h" namespace gcm { @@ -30,6 +31,7 @@ void GCMClientMock::Initialize( const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, const scoped_refptr<net::URLRequestContextGetter>& url_request_context_getter, + scoped_ptr<Encryptor> encryptor, Delegate* delegate) { delegate_ = delegate; } diff --git a/chrome/browser/services/gcm/gcm_client_mock.h b/chrome/browser/services/gcm/gcm_client_mock.h index b6e8dd9..a878a88 100644 --- a/chrome/browser/services/gcm/gcm_client_mock.h +++ b/chrome/browser/services/gcm/gcm_client_mock.h @@ -37,6 +37,7 @@ class GCMClientMock : public GCMClient { const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, const scoped_refptr<net::URLRequestContextGetter>& url_request_context_getter, + scoped_ptr<Encryptor> encryptor, Delegate* delegate) OVERRIDE; virtual void Start() OVERRIDE; virtual void Stop() OVERRIDE; diff --git a/chrome/browser/services/gcm/gcm_profile_service_factory.cc b/chrome/browser/services/gcm/gcm_profile_service_factory.cc index 437fa5f..2e380b1 100644 --- a/chrome/browser/services/gcm/gcm_profile_service_factory.cc +++ b/chrome/browser/services/gcm/gcm_profile_service_factory.cc @@ -7,10 +7,10 @@ #include "base/memory/scoped_ptr.h" #include "chrome/browser/profiles/incognito_helpers.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/services/gcm/gcm_client_factory.h" #include "chrome/browser/services/gcm/gcm_profile_service.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/browser/signin/signin_manager_factory.h" +#include "components/gcm_driver/gcm_client_factory.h" #include "components/keyed_service/content/browser_context_dependency_manager.h" #if !defined(OS_ANDROID) diff --git a/chrome/browser/services/gcm/gcm_profile_service_factory.h b/chrome/browser/services/gcm/gcm_profile_service_factory.h index 2e5763e..83ea9cb 100644 --- a/chrome/browser/services/gcm/gcm_profile_service_factory.h +++ b/chrome/browser/services/gcm/gcm_profile_service_factory.h @@ -7,6 +7,7 @@ #include "base/compiler_specific.h" #include "base/memory/singleton.h" +#include "components/gcm_driver/system_encryptor.h" #include "components/keyed_service/content/browser_context_keyed_service_factory.h" class Profile; diff --git a/chrome/browser/services/gcm/gcm_profile_service_unittest.cc b/chrome/browser/services/gcm/gcm_profile_service_unittest.cc index 6ac3ceb..df67388 100644 --- a/chrome/browser/services/gcm/gcm_profile_service_unittest.cc +++ b/chrome/browser/services/gcm/gcm_profile_service_unittest.cc @@ -13,11 +13,11 @@ #include "base/run_loop.h" #include "chrome/browser/services/gcm/fake_gcm_client_factory.h" #include "chrome/browser/services/gcm/fake_signin_manager.h" -#include "chrome/browser/services/gcm/gcm_client_factory.h" #include "chrome/browser/services/gcm/gcm_client_mock.h" #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" #include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/test/base/testing_profile.h" +#include "components/gcm_driver/gcm_client_factory.h" #include "components/user_prefs/pref_registry_syncable.h" #include "content/public/browser/browser_context.h" #include "content/public/test/test_browser_thread_bundle.h" diff --git a/chrome/browser/services/gcm/gcm_service.cc b/chrome/browser/services/gcm/gcm_service.cc index 4a33e0c..a8e6227 100644 --- a/chrome/browser/services/gcm/gcm_service.cc +++ b/chrome/browser/services/gcm/gcm_service.cc @@ -13,9 +13,10 @@ #include "base/logging.h" #include "base/sequenced_task_runner.h" #include "base/threading/sequenced_worker_pool.h" -#include "chrome/browser/services/gcm/gcm_app_handler.h" -#include "chrome/browser/services/gcm/gcm_client_factory.h" #include "chrome/common/chrome_version_info.h" +#include "components/gcm_driver/gcm_app_handler.h" +#include "components/gcm_driver/gcm_client_factory.h" +#include "components/gcm_driver/system_encryptor.h" #include "content/public/browser/browser_thread.h" #include "google_apis/gaia/oauth2_token_service.h" #include "google_apis/gcm/protocol/android_checkin.pb.h" @@ -193,7 +194,7 @@ void GCMService::IOWorker::Initialize( url_request_context_getter) { DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); - gcm_client_ = gcm_client_factory->BuildInstance().Pass(); + gcm_client_ = gcm_client_factory->BuildInstance(); checkin_proto::ChromeBuildProto chrome_build_proto; chrome_build_proto.set_platform(GetPlatform()); @@ -212,6 +213,7 @@ void GCMService::IOWorker::Initialize( account_ids, blocking_task_runner, url_request_context_getter, + make_scoped_ptr<Encryptor>(new SystemEncryptor), this); } diff --git a/chrome/browser/services/gcm/gcm_service.h b/chrome/browser/services/gcm/gcm_service.h index afa9dbe..02fe433 100644 --- a/chrome/browser/services/gcm/gcm_service.h +++ b/chrome/browser/services/gcm/gcm_service.h @@ -16,7 +16,7 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" -#include "chrome/browser/services/gcm/default_gcm_app_handler.h" +#include "components/gcm_driver/default_gcm_app_handler.h" #include "google_apis/gaia/identity_provider.h" #include "google_apis/gcm/gcm_client.h" diff --git a/chrome/browser/services/gcm/gcm_service_unittest.cc b/chrome/browser/services/gcm/gcm_service_unittest.cc index 9de63d3..575e11c 100644 --- a/chrome/browser/services/gcm/gcm_service_unittest.cc +++ b/chrome/browser/services/gcm/gcm_service_unittest.cc @@ -12,13 +12,14 @@ #include "base/run_loop.h" #include "base/strings/string_util.h" #include "chrome/browser/services/gcm/fake_gcm_client_factory.h" -#include "chrome/browser/services/gcm/gcm_app_handler.h" -#include "chrome/browser/services/gcm/gcm_client_factory.h" #include "chrome/browser/services/gcm/gcm_client_mock.h" +#include "components/gcm_driver/gcm_app_handler.h" +#include "components/gcm_driver/gcm_client_factory.h" #include "content/public/browser/browser_thread.h" #include "content/public/test/test_browser_thread_bundle.h" #include "google_apis/gaia/fake_identity_provider.h" #include "google_apis/gaia/fake_oauth2_token_service.h" +#include "google_apis/gcm/base/fake_encryptor.h" #include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_test_util.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index e4381da..cf6d7da 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -37,6 +37,7 @@ '../components/components.gyp:favicon_base', '../components/components.gyp:favicon_core', '../components/components.gyp:feedback_component', + '../components/components.gyp:gcm_driver', '../components/components.gyp:google_core_browser', '../components/components.gyp:infobars_core', '../components/components.gyp:invalidation', @@ -66,7 +67,6 @@ '../content/content.gyp:content_common', '../courgette/courgette.gyp:courgette_lib', '../crypto/crypto.gyp:crypto', - '../google_apis/gcm/gcm.gyp:gcm', '../google_apis/google_apis.gyp:google_apis', '../jingle/jingle.gyp:notifier', '../skia/skia.gyp:skia', @@ -1986,11 +1986,6 @@ 'browser/search_engines/template_url_service_observer.h', 'browser/search_engines/util.cc', 'browser/search_engines/util.h', - 'browser/services/gcm/default_gcm_app_handler.cc', - 'browser/services/gcm/default_gcm_app_handler.h', - 'browser/services/gcm/gcm_app_handler.h', - 'browser/services/gcm/gcm_client_factory.cc', - 'browser/services/gcm/gcm_client_factory.h', 'browser/services/gcm/gcm_profile_service.cc', 'browser/services/gcm/gcm_profile_service.h', 'browser/services/gcm/gcm_profile_service_factory.cc', |