summaryrefslogtreecommitdiffstats
path: root/google_apis
diff options
context:
space:
mode:
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-13 23:11:11 +0000
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-13 23:11:11 +0000
commit07243f95c726fb67abefa8a19fb9c46e2d63d8f8 (patch)
tree8c28a5186cb3a3be0085d2b34854b62c3ce2938b /google_apis
parent10506308ee11a4130fe535139bb9b08f678969da (diff)
downloadchromium_src-07243f95c726fb67abefa8a19fb9c46e2d63d8f8.zip
chromium_src-07243f95c726fb67abefa8a19fb9c46e2d63d8f8.tar.gz
chromium_src-07243f95c726fb67abefa8a19fb9c46e2d63d8f8.tar.bz2
Revert 270226 "Componentize GCM Part 1: create GCM component and..."
broke on Chrome OS: http://build.chromium.org/p/chromium.chrome/builders/Google%20Chrome%20ChromeOS/builds/67606 > Componentize GCM Part 1: create GCM component and move some files over > > BUG=356716 > TEST=existing tests > > Review URL: https://codereview.chromium.org/261853012 TBR=jianli@chromium.org Review URL: https://codereview.chromium.org/281783004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@270234 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'google_apis')
-rw-r--r--google_apis/gcm/DEPS1
-rw-r--r--google_apis/gcm/base/encryptor.h27
-rw-r--r--google_apis/gcm/base/fake_encryptor.cc24
-rw-r--r--google_apis/gcm/base/fake_encryptor.h28
-rw-r--r--google_apis/gcm/engine/gcm_store_impl.cc27
-rw-r--r--google_apis/gcm/engine/gcm_store_impl.h5
-rw-r--r--google_apis/gcm/engine/gcm_store_impl_unittest.cc9
-rw-r--r--google_apis/gcm/engine/mcs_client_unittest.cc12
-rw-r--r--google_apis/gcm/gcm.gyp6
-rw-r--r--google_apis/gcm/gcm_client.h3
-rw-r--r--google_apis/gcm/gcm_client_impl.cc5
-rw-r--r--google_apis/gcm/gcm_client_impl.h1
-rw-r--r--google_apis/gcm/gcm_client_impl_unittest.cc11
-rw-r--r--google_apis/gcm/tools/mcs_probe.cc4
14 files changed, 37 insertions, 126 deletions
diff --git a/google_apis/gcm/DEPS b/google_apis/gcm/DEPS
index 047dc156..5accad6 100644
--- a/google_apis/gcm/DEPS
+++ b/google_apis/gcm/DEPS
@@ -7,6 +7,7 @@ include_rules = [
"+base",
"+testing",
+ "+components/os_crypt",
"+google", # For third_party/protobuf/src.
"+net",
"+third_party/leveldatabase",
diff --git a/google_apis/gcm/base/encryptor.h b/google_apis/gcm/base/encryptor.h
deleted file mode 100644
index f33eb2c..0000000
--- a/google_apis/gcm/base/encryptor.h
+++ /dev/null
@@ -1,27 +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 GOOGLE_APIS_GCM_ENCRYPTOR_H_
-#define GOOGLE_APIS_GCM_ENCRYPTOR_H_
-
-#include <string>
-#include "google_apis/gcm/base/gcm_export.h"
-
-namespace gcm {
-
-class GCM_EXPORT Encryptor {
- public:
- // All methods below should be thread-safe.
- virtual bool EncryptString(const std::string& plaintext,
- std::string* ciphertext) = 0;
-
- virtual bool DecryptString(const std::string& ciphertext,
- std::string* plaintext) = 0;
-
- virtual ~Encryptor() {}
-};
-
-} // namespace gcm
-
-#endif // GOOGLE_APIS_GCM_ENCRYPTOR_H_
diff --git a/google_apis/gcm/base/fake_encryptor.cc b/google_apis/gcm/base/fake_encryptor.cc
deleted file mode 100644
index 25916da..0000000
--- a/google_apis/gcm/base/fake_encryptor.cc
+++ /dev/null
@@ -1,24 +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 "google_apis/gcm/base/fake_encryptor.h"
-
-#include "base/base64.h"
-
-namespace gcm {
-
-FakeEncryptor::~FakeEncryptor() {}
-
-bool FakeEncryptor::EncryptString(const std::string& plaintext,
- std::string* ciphertext) {
- base::Base64Encode(plaintext, ciphertext);
- return true;
-}
-
-bool FakeEncryptor::DecryptString(const std::string& ciphertext,
- std::string* plaintext) {
- return base::Base64Decode(ciphertext, plaintext);
-}
-
-} // namespace gcm
diff --git a/google_apis/gcm/base/fake_encryptor.h b/google_apis/gcm/base/fake_encryptor.h
deleted file mode 100644
index 34e631e..0000000
--- a/google_apis/gcm/base/fake_encryptor.h
+++ /dev/null
@@ -1,28 +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 GOOGLE_APIS_GCM_BASE_ENCRYPTOR_H_
-#define GOOGLE_APIS_GCM_BASE_ENCRYPTOR_H_
-
-#include "base/compiler_specific.h"
-#include "google_apis/gcm/base/encryptor.h"
-
-namespace gcm {
-
-// Encryptor which simply base64-encodes the plaintext to get the
-// ciphertext. Obviously, this should be used only for testing.
-class FakeEncryptor : public Encryptor {
- public:
- virtual ~FakeEncryptor();
-
- virtual bool EncryptString(const std::string& plaintext,
- std::string* ciphertext) OVERRIDE;
-
- virtual bool DecryptString(const std::string& ciphertext,
- std::string* plaintext) OVERRIDE;
-};
-
-} // namespace gcm
-
-#endif // GOOGLE_APIS_GCM_BASE_ENCRYPTOR_H_
diff --git a/google_apis/gcm/engine/gcm_store_impl.cc b/google_apis/gcm/engine/gcm_store_impl.cc
index 8c6f730f..5393fd1 100644
--- a/google_apis/gcm/engine/gcm_store_impl.cc
+++ b/google_apis/gcm/engine/gcm_store_impl.cc
@@ -18,7 +18,7 @@
#include "base/strings/string_piece.h"
#include "base/time/time.h"
#include "base/tracked_objects.h"
-#include "google_apis/gcm/base/encryptor.h"
+#include "components/os_crypt/os_crypt.h"
#include "google_apis/gcm/base/mcs_message.h"
#include "google_apis/gcm/base/mcs_util.h"
#include "google_apis/gcm/protocol/mcs.pb.h"
@@ -107,8 +107,7 @@ class GCMStoreImpl::Backend
: public base::RefCountedThreadSafe<GCMStoreImpl::Backend> {
public:
Backend(const base::FilePath& path,
- scoped_refptr<base::SequencedTaskRunner> foreground_runner,
- scoped_ptr<Encryptor> encryptor);
+ scoped_refptr<base::SequencedTaskRunner> foreground_runner);
// Blocking implementations of GCMStoreImpl methods.
void Load(const LoadCallback& callback);
@@ -159,19 +158,14 @@ class GCMStoreImpl::Backend
const base::FilePath path_;
scoped_refptr<base::SequencedTaskRunner> foreground_task_runner_;
- scoped_ptr<Encryptor> encryptor_;
scoped_ptr<leveldb::DB> db_;
};
GCMStoreImpl::Backend::Backend(
const base::FilePath& path,
- scoped_refptr<base::SequencedTaskRunner> foreground_task_runner,
- scoped_ptr<Encryptor> encryptor)
- : path_(path),
- foreground_task_runner_(foreground_task_runner),
- encryptor_(encryptor.Pass()) {
-}
+ scoped_refptr<base::SequencedTaskRunner> foreground_task_runner)
+ : path_(path), foreground_task_runner_(foreground_task_runner) {}
GCMStoreImpl::Backend::~Backend() {}
@@ -284,8 +278,8 @@ void GCMStoreImpl::Backend::SetDeviceCredentials(
write_options.sync = true;
std::string encrypted_token;
- encryptor_->EncryptString(base::Uint64ToString(device_security_token),
- &encrypted_token);
+ OSCrypt::EncryptString(base::Uint64ToString(device_security_token),
+ &encrypted_token);
std::string android_id_str = base::Uint64ToString(device_android_id);
leveldb::Status s =
db_->Put(write_options,
@@ -557,7 +551,7 @@ bool GCMStoreImpl::Backend::LoadDeviceCredentials(uint64* android_id,
}
if (s.ok()) {
std::string decrypted_token;
- encryptor_->DecryptString(result, &decrypted_token);
+ OSCrypt::DecryptString(result, &decrypted_token);
if (!base::StringToUint64(decrypted_token, security_token)) {
LOG(ERROR) << "Failed to restore security token.";
return false;
@@ -705,11 +699,8 @@ bool GCMStoreImpl::Backend::LoadGServicesSettings(
GCMStoreImpl::GCMStoreImpl(
const base::FilePath& path,
- scoped_refptr<base::SequencedTaskRunner> blocking_task_runner,
- scoped_ptr<Encryptor> encryptor)
- : backend_(new Backend(path,
- base::MessageLoopProxy::current(),
- encryptor.Pass())),
+ scoped_refptr<base::SequencedTaskRunner> blocking_task_runner)
+ : backend_(new Backend(path, base::MessageLoopProxy::current())),
blocking_task_runner_(blocking_task_runner),
weak_ptr_factory_(this) {
}
diff --git a/google_apis/gcm/engine/gcm_store_impl.h b/google_apis/gcm/engine/gcm_store_impl.h
index f49509a..e46c503 100644
--- a/google_apis/gcm/engine/gcm_store_impl.h
+++ b/google_apis/gcm/engine/gcm_store_impl.h
@@ -18,16 +18,13 @@ class SequencedTaskRunner;
namespace gcm {
-class Encryptor;
-
// An implementation of GCM Store that uses LevelDB for persistence.
// It performs all blocking operations on the blocking task runner, and posts
// all callbacks to the thread on which the GCMStoreImpl is created.
class GCM_EXPORT GCMStoreImpl : public GCMStore {
public:
GCMStoreImpl(const base::FilePath& path,
- scoped_refptr<base::SequencedTaskRunner> blocking_task_runner,
- scoped_ptr<Encryptor> encryptor);
+ scoped_refptr<base::SequencedTaskRunner> blocking_task_runner);
virtual ~GCMStoreImpl();
// Load the directory and pass the initial state back to caller.
diff --git a/google_apis/gcm/engine/gcm_store_impl_unittest.cc b/google_apis/gcm/engine/gcm_store_impl_unittest.cc
index 7b9c893..a587bc1198 100644
--- a/google_apis/gcm/engine/gcm_store_impl_unittest.cc
+++ b/google_apis/gcm/engine/gcm_store_impl_unittest.cc
@@ -15,7 +15,7 @@
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
-#include "google_apis/gcm/base/fake_encryptor.h"
+#include "components/os_crypt/os_crypt_switches.h"
#include "google_apis/gcm/base/mcs_message.h"
#include "google_apis/gcm/base/mcs_util.h"
#include "google_apis/gcm/protocol/mcs.pb.h"
@@ -76,13 +76,16 @@ GCMStoreImplTest::~GCMStoreImplTest() {}
void GCMStoreImplTest::SetUp() {
testing::Test::SetUp();
+#if defined(OS_MACOSX)
+ base::CommandLine::ForCurrentProcess()->AppendSwitch(
+ os_crypt::switches::kUseMockKeychain);
+#endif // OS_MACOSX
}
scoped_ptr<GCMStore> GCMStoreImplTest::BuildGCMStore() {
return scoped_ptr<GCMStore>(new GCMStoreImpl(
temp_directory_.path(),
- message_loop_.message_loop_proxy(),
- make_scoped_ptr<Encryptor>(new FakeEncryptor)));
+ message_loop_.message_loop_proxy()));
}
std::string GCMStoreImplTest::GetNextPersistentId() {
diff --git a/google_apis/gcm/engine/mcs_client_unittest.cc b/google_apis/gcm/engine/mcs_client_unittest.cc
index 3e94532..a062136 100644
--- a/google_apis/gcm/engine/mcs_client_unittest.cc
+++ b/google_apis/gcm/engine/mcs_client_unittest.cc
@@ -10,7 +10,7 @@
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/simple_test_clock.h"
-#include "google_apis/gcm/base/fake_encryptor.h"
+#include "components/os_crypt/os_crypt_switches.h"
#include "google_apis/gcm/base/mcs_util.h"
#include "google_apis/gcm/engine/fake_connection_factory.h"
#include "google_apis/gcm/engine/fake_connection_handler.h"
@@ -159,13 +159,15 @@ MCSClientTest::~MCSClientTest() {}
void MCSClientTest::SetUp() {
testing::Test::SetUp();
+#if defined(OS_MACOSX)
+ base::CommandLine::ForCurrentProcess()->AppendSwitch(
+ os_crypt::switches::kUseMockKeychain);
+#endif // OS_MACOSX
}
void MCSClientTest::BuildMCSClient() {
- gcm_store_.reset(new GCMStoreImpl(
- temp_directory_.path(),
- message_loop_.message_loop_proxy(),
- make_scoped_ptr<Encryptor>(new FakeEncryptor)));
+ gcm_store_.reset(new GCMStoreImpl(temp_directory_.path(),
+ message_loop_.message_loop_proxy()));
mcs_client_.reset(new TestMCSClient(&clock_,
&connection_factory_,
gcm_store_.get(),
diff --git a/google_apis/gcm/gcm.gyp b/google_apis/gcm/gcm.gyp
index 670b0a1..3f40c8d 100644
--- a/google_apis/gcm/gcm.gyp
+++ b/google_apis/gcm/gcm.gyp
@@ -31,6 +31,7 @@
'dependencies': [
'../../base/base.gyp:base',
'../../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
+ '../../components/components.gyp:os_crypt',
'../../net/net.gyp:net',
'../../third_party/leveldatabase/leveldatabase.gyp:leveldatabase',
'../../third_party/protobuf/protobuf.gyp:protobuf_lite',
@@ -100,8 +101,6 @@
'gcm'
],
'sources': [
- 'base/fake_encryptor.cc',
- 'base/fake_encryptor.h',
'tools/mcs_probe.cc',
],
},
@@ -120,6 +119,7 @@
'dependencies': [
'../../base/base.gyp:run_all_unittests',
'../../base/base.gyp:base',
+ '../../components/components.gyp:os_crypt',
'../../net/net.gyp:net',
'../../net/net.gyp:net_test_support',
'../../testing/gtest.gyp:gtest',
@@ -127,8 +127,6 @@
'gcm'
],
'sources': [
- 'base/fake_encryptor.cc',
- 'base/fake_encryptor.h',
'base/mcs_message_unittest.cc',
'base/mcs_util_unittest.cc',
'base/socket_stream_unittest.cc',
diff --git a/google_apis/gcm/gcm_client.h b/google_apis/gcm/gcm_client.h
index dc65967..bee154b 100644
--- a/google_apis/gcm/gcm_client.h
+++ b/google_apis/gcm/gcm_client.h
@@ -30,8 +30,6 @@ class URLRequestContextGetter;
namespace gcm {
-class Encryptor;
-
// Interface that encapsulates the network communications with the Google Cloud
// Messaging server. This interface is not supposed to be thread-safe.
class GCM_EXPORT GCMClient {
@@ -185,7 +183,6 @@ class GCM_EXPORT GCMClient {
const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner,
const scoped_refptr<net::URLRequestContextGetter>&
url_request_context_getter,
- scoped_ptr<Encryptor> encryptor,
Delegate* delegate) = 0;
// Starts the GCM service by first loading the data from the persistent store.
diff --git a/google_apis/gcm/gcm_client_impl.cc b/google_apis/gcm/gcm_client_impl.cc
index 4065d65..ed9838c 100644
--- a/google_apis/gcm/gcm_client_impl.cc
+++ b/google_apis/gcm/gcm_client_impl.cc
@@ -14,7 +14,6 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/time/default_clock.h"
-#include "google_apis/gcm/base/encryptor.h"
#include "google_apis/gcm/base/mcs_message.h"
#include "google_apis/gcm/base/mcs_util.h"
#include "google_apis/gcm/engine/checkin_request.h"
@@ -207,7 +206,6 @@ void GCMClientImpl::Initialize(
const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner,
const scoped_refptr<net::URLRequestContextGetter>&
url_request_context_getter,
- scoped_ptr<Encryptor> encryptor,
GCMClient::Delegate* delegate) {
DCHECK_EQ(UNINITIALIZED, state_);
DCHECK(url_request_context_getter);
@@ -223,8 +221,7 @@ void GCMClientImpl::Initialize(
chrome_build_proto_.CopyFrom(chrome_build_proto);
account_ids_ = account_ids;
- gcm_store_.reset(
- new GCMStoreImpl(path, blocking_task_runner, encryptor.Pass()));
+ gcm_store_.reset(new GCMStoreImpl(path, blocking_task_runner));
delegate_ = delegate;
diff --git a/google_apis/gcm/gcm_client_impl.h b/google_apis/gcm/gcm_client_impl.h
index 5c4c84a..5555ca3 100644
--- a/google_apis/gcm/gcm_client_impl.h
+++ b/google_apis/gcm/gcm_client_impl.h
@@ -87,7 +87,6 @@ class GCM_EXPORT GCMClientImpl
const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner,
const scoped_refptr<net::URLRequestContextGetter>&
url_request_context_getter,
- scoped_ptr<Encryptor> encryptor,
GCMClient::Delegate* delegate) OVERRIDE;
virtual void Start() OVERRIDE;
virtual void Stop() OVERRIDE;
diff --git a/google_apis/gcm/gcm_client_impl_unittest.cc b/google_apis/gcm/gcm_client_impl_unittest.cc
index 7fc0e49..010660a 100644
--- a/google_apis/gcm/gcm_client_impl_unittest.cc
+++ b/google_apis/gcm/gcm_client_impl_unittest.cc
@@ -10,7 +10,7 @@
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/time/clock.h"
-#include "google_apis/gcm/base/fake_encryptor.h"
+#include "components/os_crypt/os_crypt_switches.h"
#include "google_apis/gcm/base/mcs_message.h"
#include "google_apis/gcm/base/mcs_util.h"
#include "google_apis/gcm/engine/fake_connection_factory.h"
@@ -330,6 +330,10 @@ GCMClientImplTest::~GCMClientImplTest() {}
void GCMClientImplTest::SetUp() {
testing::Test::SetUp();
+#if defined(OS_MACOSX)
+ base::CommandLine::ForCurrentProcess()->AppendSwitch(
+ os_crypt::switches::kUseMockKeychain);
+#endif // OS_MACOSX
ASSERT_TRUE(CreateUniqueTempDir());
InitializeLoop();
BuildGCMClient(base::TimeDelta());
@@ -450,7 +454,6 @@ void GCMClientImplTest::InitializeGCMClient() {
std::vector<std::string>(),
message_loop_.message_loop_proxy(),
url_request_context_getter_,
- make_scoped_ptr<Encryptor>(new FakeEncryptor),
this);
// Start loading and check-in.
@@ -699,6 +702,10 @@ GCMClientImplCheckinTest::~GCMClientImplCheckinTest() {
void GCMClientImplCheckinTest::SetUp() {
testing::Test::SetUp();
+#if defined(OS_MACOSX)
+ base::CommandLine::ForCurrentProcess()->AppendSwitch(
+ os_crypt::switches::kUseMockKeychain);
+#endif // OS_MACOSX
// Creating unique temp directory that will be used by GCMStore shared between
// GCM Client and G-services settings.
ASSERT_TRUE(CreateUniqueTempDir());
diff --git a/google_apis/gcm/tools/mcs_probe.cc b/google_apis/gcm/tools/mcs_probe.cc
index 3f93fd0..b7f984d 100644
--- a/google_apis/gcm/tools/mcs_probe.cc
+++ b/google_apis/gcm/tools/mcs_probe.cc
@@ -23,7 +23,6 @@
#include "base/threading/worker_pool.h"
#include "base/time/default_clock.h"
#include "base/values.h"
-#include "google_apis/gcm/base/fake_encryptor.h"
#include "google_apis/gcm/base/mcs_message.h"
#include "google_apis/gcm/base/mcs_util.h"
#include "google_apis/gcm/engine/checkin_request.h"
@@ -307,8 +306,7 @@ void MCSProbe::Start() {
&recorder_));
gcm_store_.reset(
new GCMStoreImpl(gcm_store_path_,
- file_thread_.message_loop_proxy(),
- make_scoped_ptr<Encryptor>(new FakeEncryptor)));
+ file_thread_.message_loop_proxy()));
mcs_client_.reset(new MCSClient("probe",
&clock_,
connection_factory_.get(),