| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/download/download_service.h" | 10 #include "chrome/browser/download/download_service.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 //===================== GDataSystemService ==================================== | 28 //===================== GDataSystemService ==================================== |
| 29 GDataSystemService::GDataSystemService(Profile* profile) | 29 GDataSystemService::GDataSystemService(Profile* profile) |
| 30 : profile_(profile), | 30 : profile_(profile), |
| 31 sequence_token_(BrowserThread::GetBlockingPool()->GetSequenceToken()), | 31 sequence_token_(BrowserThread::GetBlockingPool()->GetSequenceToken()), |
| 32 cache_(GDataCache::CreateGDataCacheOnUIThread( | 32 cache_(GDataCache::CreateGDataCacheOnUIThread( |
| 33 GDataCache::GetCacheRootPath(profile_), | 33 GDataCache::GetCacheRootPath(profile_), |
| 34 BrowserThread::GetBlockingPool(), | 34 BrowserThread::GetBlockingPool(), |
| 35 sequence_token_)), | 35 sequence_token_)), |
| 36 documents_service_(new DocumentsService), | 36 documents_service_(new DocumentsService), |
| 37 uploader_(new GDataUploader(docs_service())), |
| 37 file_system_(new GDataFileSystem(profile, | 38 file_system_(new GDataFileSystem(profile, |
| 38 cache(), | 39 cache(), |
| 39 docs_service(), | 40 docs_service(), |
| 41 uploader(), |
| 40 sequence_token_)), | 42 sequence_token_)), |
| 41 uploader_(new GDataUploader(file_system(), docs_service())), | |
| 42 download_observer_(new GDataDownloadObserver), | 43 download_observer_(new GDataDownloadObserver), |
| 43 sync_client_(new GDataSyncClient(profile, file_system(), cache())), | 44 sync_client_(new GDataSyncClient(profile, file_system(), cache())), |
| 44 webapps_registry_(new DriveWebAppsRegistry) { | 45 webapps_registry_(new DriveWebAppsRegistry) { |
| 45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 46 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 47 |
| 48 // TODO(satorux): The dependency to GDataFileSystem should be |
| 49 // eliminated. http://crbug.com/133860 |
| 50 uploader_->set_file_system(file_system()); |
| 46 } | 51 } |
| 47 | 52 |
| 48 GDataSystemService::~GDataSystemService() { | 53 GDataSystemService::~GDataSystemService() { |
| 49 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 54 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 50 cache_->DestroyOnUIThread(); | 55 cache_->DestroyOnUIThread(); |
| 51 } | 56 } |
| 52 | 57 |
| 53 void GDataSystemService::Initialize() { | 58 void GDataSystemService::Initialize() { |
| 54 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 59 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 55 | 60 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 67 GDataCache::CACHE_TYPE_TMP_DOWNLOADS)); | 72 GDataCache::CACHE_TYPE_TMP_DOWNLOADS)); |
| 68 } | 73 } |
| 69 | 74 |
| 70 void GDataSystemService::Shutdown() { | 75 void GDataSystemService::Shutdown() { |
| 71 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 72 | 77 |
| 73 // Shut down the member objects in the reverse order of creation. | 78 // Shut down the member objects in the reverse order of creation. |
| 74 webapps_registry_.reset(); | 79 webapps_registry_.reset(); |
| 75 sync_client_.reset(); | 80 sync_client_.reset(); |
| 76 download_observer_.reset(); | 81 download_observer_.reset(); |
| 82 file_system_.reset(); |
| 77 uploader_.reset(); | 83 uploader_.reset(); |
| 78 file_system_.reset(); | |
| 79 documents_service_.reset(); | 84 documents_service_.reset(); |
| 80 } | 85 } |
| 81 | 86 |
| 82 //===================== GDataSystemServiceFactory ============================= | 87 //===================== GDataSystemServiceFactory ============================= |
| 83 | 88 |
| 84 // static | 89 // static |
| 85 GDataSystemService* GDataSystemServiceFactory::GetForProfile( | 90 GDataSystemService* GDataSystemServiceFactory::GetForProfile( |
| 86 Profile* profile) { | 91 Profile* profile) { |
| 87 return static_cast<GDataSystemService*>( | 92 return static_cast<GDataSystemService*>( |
| 88 GetInstance()->GetServiceForProfile(profile, true)); | 93 GetInstance()->GetServiceForProfile(profile, true)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 110 } | 115 } |
| 111 | 116 |
| 112 ProfileKeyedService* GDataSystemServiceFactory::BuildServiceInstanceFor( | 117 ProfileKeyedService* GDataSystemServiceFactory::BuildServiceInstanceFor( |
| 113 Profile* profile) const { | 118 Profile* profile) const { |
| 114 GDataSystemService* service = new GDataSystemService(profile); | 119 GDataSystemService* service = new GDataSystemService(profile); |
| 115 service->Initialize(); | 120 service->Initialize(); |
| 116 return service; | 121 return service; |
| 117 } | 122 } |
| 118 | 123 |
| 119 } // namespace gdata | 124 } // namespace gdata |
| OLD | NEW |