Chromium Code Reviews| Index: google_apis/gcm/engine/gcm_internals_builder.cc |
| diff --git a/google_apis/gcm/engine/gcm_internals_builder.cc b/google_apis/gcm/engine/gcm_internals_builder.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..bc529c3577bca3d3e43198d5b1b594f70a41e74f |
| --- /dev/null |
| +++ b/google_apis/gcm/engine/gcm_internals_builder.cc |
| @@ -0,0 +1,64 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
|
jianli
2014/04/09 23:36:58
2014
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "google_apis/gcm/engine/gcm_internals_builder.h" |
| + |
| +#include "base/files/file_path.h" |
| +#include "base/sequenced_task_runner.h" |
| +#include "base/time/default_clock.h" |
| +#include "components/os_crypt/os_crypt.h" |
| +#include "google_apis/gcm/engine/connection_factory_impl.h" |
| +#include "google_apis/gcm/engine/gcm_store_impl.h" |
| +#include "google_apis/gcm/engine/mcs_client.h" |
| +#include "net/http/http_network_session.h" |
| +#include "url/gurl.h" |
| + |
| +namespace gcm { |
| + |
| +GCMInternalsBuilder::GCMInternalsBuilder() : testing_(false) {} |
| +GCMInternalsBuilder::~GCMInternalsBuilder() {} |
|
jianli
2014/04/09 23:36:58
nit: empty line above
|
| + |
| +scoped_ptr<base::Clock> GCMInternalsBuilder::BuildClock() { |
| + return make_scoped_ptr<base::Clock>(new base::DefaultClock()); |
| +} |
| + |
| +scoped_ptr<GCMStore> GCMInternalsBuilder::BuildGCMStore( |
| + const base::FilePath& path, |
| + const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner) { |
| +#if defined(OS_MACOSX) |
| + OSCrypt::UseMockKeychain(testing_); |
| +#endif |
| + return make_scoped_ptr<GCMStore>( |
| + new GCMStoreImpl(path, blocking_task_runner)); |
| +} |
| + |
| +scoped_ptr<MCSClient> GCMInternalsBuilder::BuildMCSClient( |
| + const std::string& version, |
| + base::Clock* clock, |
| + ConnectionFactory* connection_factory, |
| + GCMStore* gcm_store) { |
| + return make_scoped_ptr<MCSClient>( |
| + new MCSClient(version, |
| + clock, |
| + connection_factory, |
| + gcm_store)); |
| +} |
| + |
| +scoped_ptr<ConnectionFactory> GCMInternalsBuilder::BuildConnectionFactory( |
| + const std::vector<GURL>& endpoints, |
| + const net::BackoffEntry::Policy& backoff_policy, |
| + scoped_refptr<net::HttpNetworkSession> network_session, |
| + net::NetLog* net_log) { |
| + return make_scoped_ptr<ConnectionFactory>( |
| + new ConnectionFactoryImpl(endpoints, |
| + backoff_policy, |
| + network_session, |
| + net_log)); |
| +} |
| + |
| +void GCMInternalsBuilder::SetUpForTesting() { |
| + testing_ = true; |
| +} |
| + |
| +} // namespace gcm |