summaryrefslogtreecommitdiffstats
path: root/google_apis/gcm
diff options
context:
space:
mode:
authorzea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-22 10:32:06 +0000
committerzea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-22 10:32:06 +0000
commit4ac6c4ebf926d6edebbc5f47e9a18536bfdc43dc (patch)
treee9eb19f6f4b2259355dd37411b5c386449b7e6f3 /google_apis/gcm
parent304875dd89f326d20dcf6c85639592365f126c71 (diff)
downloadchromium_src-4ac6c4ebf926d6edebbc5f47e9a18536bfdc43dc.zip
chromium_src-4ac6c4ebf926d6edebbc5f47e9a18536bfdc43dc.tar.gz
chromium_src-4ac6c4ebf926d6edebbc5f47e9a18536bfdc43dc.tar.bz2
[GCM] Plumb mock keychain status to gcm store impl
The UseMockKeychain call must be done from within the same library as the encryptor is used. To get around this we pass the mock status as a parameter at construction time. BUG=284553 Review URL: https://codereview.chromium.org/140903005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@246274 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'google_apis/gcm')
-rw-r--r--google_apis/gcm/engine/gcm_store_impl.cc8
-rw-r--r--google_apis/gcm/engine/gcm_store_impl.h3
-rw-r--r--google_apis/gcm/engine/gcm_store_impl_unittest.cc10
-rw-r--r--google_apis/gcm/engine/mcs_client_unittest.cc9
-rw-r--r--google_apis/gcm/engine/user_list_unittest.cc3
-rw-r--r--google_apis/gcm/gcm_client_impl.cc4
-rw-r--r--google_apis/gcm/tools/mcs_probe.cc4
7 files changed, 22 insertions, 19 deletions
diff --git a/google_apis/gcm/engine/gcm_store_impl.cc b/google_apis/gcm/engine/gcm_store_impl.cc
index 90019b9..78c78ff 100644
--- a/google_apis/gcm/engine/gcm_store_impl.cc
+++ b/google_apis/gcm/engine/gcm_store_impl.cc
@@ -605,11 +605,17 @@ bool GCMStoreImpl::Backend::LoadUserSerialNumberMap(
}
GCMStoreImpl::GCMStoreImpl(
+ bool use_mock_keychain,
const base::FilePath& path,
scoped_refptr<base::SequencedTaskRunner> blocking_task_runner)
: backend_(new Backend(path, base::MessageLoopProxy::current())),
blocking_task_runner_(blocking_task_runner),
- weak_ptr_factory_(this) {}
+ weak_ptr_factory_(this) {
+// On OSX, prevent the Keychain permissions popup during unit tests.
+#if defined(OS_MACOSX)
+ Encryptor::UseMockKeychain(use_mock_keychain);
+#endif
+}
GCMStoreImpl::~GCMStoreImpl() {}
diff --git a/google_apis/gcm/engine/gcm_store_impl.h b/google_apis/gcm/engine/gcm_store_impl.h
index 00af3a2b..8c1e08c 100644
--- a/google_apis/gcm/engine/gcm_store_impl.h
+++ b/google_apis/gcm/engine/gcm_store_impl.h
@@ -23,7 +23,8 @@ namespace gcm {
// all callbacks to the thread on which the GCMStoreImpl is created.
class GCM_EXPORT GCMStoreImpl : public GCMStore {
public:
- GCMStoreImpl(const base::FilePath& path,
+ GCMStoreImpl(bool use_mock_keychain,
+ const base::FilePath& path,
scoped_refptr<base::SequencedTaskRunner> blocking_task_runner);
virtual ~GCMStoreImpl();
diff --git a/google_apis/gcm/engine/gcm_store_impl_unittest.cc b/google_apis/gcm/engine/gcm_store_impl_unittest.cc
index c3dbcb3..7575703 100644
--- a/google_apis/gcm/engine/gcm_store_impl_unittest.cc
+++ b/google_apis/gcm/engine/gcm_store_impl_unittest.cc
@@ -14,7 +14,6 @@
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
-#include "components/webdata/encryptor/encryptor.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"
@@ -65,18 +64,15 @@ GCMStoreImplTest::GCMStoreImplTest()
: expected_success_(true) {
EXPECT_TRUE(temp_directory_.CreateUniqueTempDir());
run_loop_.reset(new base::RunLoop());
-
-// On OSX, prevent the Keychain permissions popup during unit tests.
-#if defined(OS_MACOSX)
- Encryptor::UseMockKeychain(true);
-#endif
}
GCMStoreImplTest::~GCMStoreImplTest() {}
scoped_ptr<GCMStore> GCMStoreImplTest::BuildGCMStore() {
return scoped_ptr<GCMStore>(new GCMStoreImpl(
- temp_directory_.path(), message_loop_.message_loop_proxy()));
+ true,
+ temp_directory_.path(),
+ 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 d5fdf23..e5b7ce7 100644
--- a/google_apis/gcm/engine/mcs_client_unittest.cc
+++ b/google_apis/gcm/engine/mcs_client_unittest.cc
@@ -9,7 +9,6 @@
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/simple_test_clock.h"
-#include "components/webdata/encryptor/encryptor.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"
@@ -129,11 +128,6 @@ MCSClientTest::MCSClientTest()
EXPECT_TRUE(temp_directory_.CreateUniqueTempDir());
run_loop_.reset(new base::RunLoop());
- // On OSX, prevent the Keychain permissions popup during unit tests.
-#if defined(OS_MACOSX)
- Encryptor::UseMockKeychain(true);
-#endif
-
// Advance the clock to a non-zero time.
clock_.Advance(base::TimeDelta::FromSeconds(1));
}
@@ -141,7 +135,8 @@ MCSClientTest::MCSClientTest()
MCSClientTest::~MCSClientTest() {}
void MCSClientTest::BuildMCSClient() {
- gcm_store_.reset(new GCMStoreImpl(temp_directory_.path(),
+ gcm_store_.reset(new GCMStoreImpl(true,
+ temp_directory_.path(),
message_loop_.message_loop_proxy()));
mcs_client_.reset(new TestMCSClient(&clock_,
&connection_factory_,
diff --git a/google_apis/gcm/engine/user_list_unittest.cc b/google_apis/gcm/engine/user_list_unittest.cc
index de225ea..e07f68d 100644
--- a/google_apis/gcm/engine/user_list_unittest.cc
+++ b/google_apis/gcm/engine/user_list_unittest.cc
@@ -109,7 +109,8 @@ void UserListTest::SetDelegateCallback(const std::string& username,
}
scoped_ptr<UserList> UserListTest::BuildUserList() {
- gcm_store_.reset(new GCMStoreImpl(temp_directory_.path(),
+ gcm_store_.reset(new GCMStoreImpl(true,
+ temp_directory_.path(),
message_loop_.message_loop_proxy()));
return scoped_ptr<UserList>(new UserList(gcm_store_.get()));
}
diff --git a/google_apis/gcm/gcm_client_impl.cc b/google_apis/gcm/gcm_client_impl.cc
index 8d09050..eea2a75 100644
--- a/google_apis/gcm/gcm_client_impl.cc
+++ b/google_apis/gcm/gcm_client_impl.cc
@@ -21,7 +21,9 @@ GCMClientImpl::~GCMClientImpl() {
void GCMClientImpl::Initialize(
const base::FilePath& path,
scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) {
- gcm_store_.reset(new GCMStoreImpl(path, blocking_task_runner));
+ gcm_store_.reset(new GCMStoreImpl(false,
+ path,
+ blocking_task_runner));
user_list_.reset(new UserList(gcm_store_.get()));
}
diff --git a/google_apis/gcm/tools/mcs_probe.cc b/google_apis/gcm/tools/mcs_probe.cc
index de1e4b8..d6d12d5 100644
--- a/google_apis/gcm/tools/mcs_probe.cc
+++ b/google_apis/gcm/tools/mcs_probe.cc
@@ -263,7 +263,9 @@ void MCSProbe::Start() {
network_session_,
&net_log_));
gcm_store_.reset(
- new GCMStoreImpl(gcm_store_path_, file_thread_.message_loop_proxy()));
+ new GCMStoreImpl(true,
+ gcm_store_path_,
+ file_thread_.message_loop_proxy()));
mcs_client_.reset(new MCSClient(&clock_,
connection_factory_.get(),
gcm_store_.get()));