Chromium Code Reviews| Index: chrome/browser/sync/profile_sync_components_factory_impl.cc |
| diff --git a/chrome/browser/sync/profile_sync_components_factory_impl.cc b/chrome/browser/sync/profile_sync_components_factory_impl.cc |
| index 9624fe502411fa25c9687193e70479927d9108a4..108a3a961d972caa74a951c629f6284c77bb3e2e 100644 |
| --- a/chrome/browser/sync/profile_sync_components_factory_impl.cc |
| +++ b/chrome/browser/sync/profile_sync_components_factory_impl.cc |
| @@ -60,12 +60,14 @@ |
| #include "components/sync_driver/ui_data_type_controller.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "extensions/browser/extension_system.h" |
| +#include "google_apis/gaia/oauth2_token_service_request.h" |
| +#include "net/url_request/url_request_context_getter.h" |
| #include "sync/api/attachments/attachment_service.h" |
| #include "sync/api/attachments/attachment_service_impl.h" |
| #include "sync/api/syncable_service.h" |
| +#include "sync/internal_api/public/attachments/attachment_uploader_impl.h" |
| #include "sync/internal_api/public/attachments/fake_attachment_downloader.h" |
| #include "sync/internal_api/public/attachments/fake_attachment_store.h" |
| -#include "sync/internal_api/public/attachments/fake_attachment_uploader.h" |
| #if defined(ENABLE_EXTENSIONS) |
| #include "chrome/browser/extensions/api/storage/settings_sync_util.h" |
| @@ -142,14 +144,26 @@ syncer::ModelTypeSet GetEnabledTypesFromCommandLine( |
| } // namespace |
| ProfileSyncComponentsFactoryImpl::ProfileSyncComponentsFactoryImpl( |
| - Profile* profile, CommandLine* command_line) |
| + Profile* profile, |
| + CommandLine* command_line, |
| + const GURL& sync_service_url, |
| + const std::string& account_id, |
| + const OAuth2TokenService::ScopeSet& scope_set, |
| + OAuth2TokenService* token_service, |
| + net::URLRequestContextGetter* url_request_context_getter) |
| : profile_(profile), |
| command_line_(command_line), |
| extension_system_(extensions::ExtensionSystem::Get(profile)), |
| - web_data_service_( |
| - WebDataServiceFactory::GetAutofillWebDataForProfile( |
| - profile_, Profile::EXPLICIT_ACCESS)), |
| + web_data_service_(WebDataServiceFactory::GetAutofillWebDataForProfile( |
| + profile_, Profile::EXPLICIT_ACCESS)), |
| + sync_service_url_(sync_service_url), |
| + account_id_(account_id), |
| + scope_set_(scope_set), |
| + token_service_(token_service), |
| + url_request_context_getter_(url_request_context_getter), |
| weak_factory_(this) { |
| + DCHECK(token_service_); |
| + DCHECK(url_request_context_getter_); |
| } |
| ProfileSyncComponentsFactoryImpl::~ProfileSyncComponentsFactoryImpl() { |
| @@ -576,14 +590,62 @@ base::WeakPtr<syncer::SyncableService> ProfileSyncComponentsFactoryImpl:: |
| } |
| } |
| +class TokenServiceProvider |
| + : public OAuth2TokenServiceRequest::TokenServiceProvider { |
| + public: |
| + TokenServiceProvider( |
| + const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| + OAuth2TokenService* token_service); |
| + virtual ~TokenServiceProvider(); |
| + |
| + // OAuth2TokenServiceRequest::TokenServiceProvider implementation. |
| + virtual scoped_refptr<base::SingleThreadTaskRunner> |
| + GetTokenServiceTaskRunner() OVERRIDE; |
| + virtual OAuth2TokenService* GetTokenService() OVERRIDE; |
| + |
| + private: |
| + scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| + OAuth2TokenService* token_service_; |
| +}; |
| + |
| +TokenServiceProvider::TokenServiceProvider( |
| + const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| + OAuth2TokenService* token_service) |
| + : task_runner_(task_runner), token_service_(token_service) { |
| +} |
| + |
| +TokenServiceProvider::~TokenServiceProvider() { |
| +} |
| + |
| +scoped_refptr<base::SingleThreadTaskRunner> |
| +TokenServiceProvider::GetTokenServiceTaskRunner() { |
| + return task_runner_; |
| +} |
| + |
| +OAuth2TokenService* TokenServiceProvider::GetTokenService() { |
| + return token_service_; |
| +} |
| + |
| scoped_ptr<syncer::AttachmentService> |
| ProfileSyncComponentsFactoryImpl::CreateAttachmentService( |
| syncer::AttachmentService::Delegate* delegate) { |
| - // TODO(maniscalco): Use a shared (one per profile) thread-safe instances of |
| + std::string url_prefix = sync_service_url_.spec() + "/attachments/"; |
|
tim (not reviewing)
2014/06/18 02:59:47
Can "/attachments" be a const somewhere? And bett
maniscalco
2014/06/18 03:56:43
Done.
|
| + scoped_ptr<OAuth2TokenServiceRequest::TokenServiceProvider> |
| + token_service_provider(new TokenServiceProvider( |
| + content::BrowserThread::GetMessageLoopProxyForThread( |
| + content::BrowserThread::UI), |
| + token_service_)); |
| + |
| + // TODO(maniscalco): Use shared (one per profile) thread-safe instances of |
| // AttachmentUploader and AttachmentDownloader instead of creating a new one |
| // per AttachmentService (bug 369536). |
| scoped_ptr<syncer::AttachmentUploader> attachment_uploader( |
| - new syncer::FakeAttachmentUploader); |
| + new syncer::AttachmentUploaderImpl(url_prefix, |
| + url_request_context_getter_, |
| + account_id_, |
| + scope_set_, |
| + token_service_provider.Pass())); |
| + |
| scoped_ptr<syncer::AttachmentDownloader> attachment_downloader( |
| new syncer::FakeAttachmentDownloader()); |