diff options
author | jianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-13 22:25:24 +0000 |
---|---|---|
committer | jianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-13 22:25:24 +0000 |
commit | 5375f66d9604e7d6b2cd8a3d4b15e3b34b5878a5 (patch) | |
tree | 6d7c835d9e8487d8b68c179a394217483a3f9064 /chrome/browser/services | |
parent | 94e20d445e63f4167fb84a9364fc6cfa53cfd0e3 (diff) | |
download | chromium_src-5375f66d9604e7d6b2cd8a3d4b15e3b34b5878a5.zip chromium_src-5375f66d9604e7d6b2cd8a3d4b15e3b34b5878a5.tar.gz chromium_src-5375f66d9604e7d6b2cd8a3d4b15e3b34b5878a5.tar.bz2 |
Componentize GCM Part 1: create GCM component and move some files over
BUG=356716
TEST=existing tests
Review URL: https://codereview.chromium.org/261853012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@270226 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/services')
14 files changed, 16 insertions, 177 deletions
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 deleted file mode 100644 index e53a25b..0000000 --- a/chrome/browser/services/gcm/gcm_app_handler.h +++ /dev/null @@ -1,42 +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_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_ 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" |