Chromium Code Reviews| 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 10 matching lines...) Expand all Loading... | |
| 21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 22 | 22 |
| 23 using content::BrowserContext; | 23 using content::BrowserContext; |
| 24 using content::BrowserThread; | 24 using content::BrowserThread; |
| 25 | 25 |
| 26 namespace gdata { | 26 namespace gdata { |
| 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()), | |
| 32 cache_( | |
|
achuithb
2012/06/12 08:17:43
I think GDataCache creation needs to happen on the
hashimoto
2012/06/12 08:22:55
Current code creates GDataCache on the UI thread,
achuithb
2012/06/12 08:36:54
Yea - can we add back the comment and TODO then?
hashimoto
2012/06/12 08:40:51
Done.
| |
| 33 GDataCache::CreateGDataCache(GDataCache::GetCacheRootPath(profile_), | |
| 34 BrowserThread::GetBlockingPool(), | |
| 35 sequence_token_)), | |
| 31 documents_service_(new DocumentsService), | 36 documents_service_(new DocumentsService), |
| 32 file_system_(new GDataFileSystem(profile, docs_service())), | 37 file_system_(new GDataFileSystem(profile, |
| 38 cache(), | |
| 39 docs_service(), | |
| 40 sequence_token_)), | |
| 33 uploader_(new GDataUploader(file_system(), docs_service())), | 41 uploader_(new GDataUploader(file_system(), docs_service())), |
| 34 download_observer_(new GDataDownloadObserver), | 42 download_observer_(new GDataDownloadObserver), |
| 35 sync_client_(new GDataSyncClient(profile, file_system())), | 43 sync_client_(new GDataSyncClient(profile, file_system(), cache())), |
| 36 webapps_registry_(new DriveWebAppsRegistry) { | 44 webapps_registry_(new DriveWebAppsRegistry) { |
| 37 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 38 } | 46 } |
| 39 | 47 |
| 40 GDataSystemService::~GDataSystemService() { | 48 GDataSystemService::~GDataSystemService() { |
| 41 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 49 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 50 BrowserThread::GetBlockingPool()->GetSequencedTaskRunner(sequence_token_) | |
| 51 ->PostTask( | |
| 52 FROM_HERE, | |
| 53 base::Bind(&base::DeletePointer<GDataCache>, cache_.release())); | |
| 42 } | 54 } |
| 43 | 55 |
| 44 void GDataSystemService::Initialize() { | 56 void GDataSystemService::Initialize() { |
| 45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 46 | 58 |
| 47 // This order is necessary so the sync_client_ doesn't miss | 59 // This order is necessary so the sync_client_ doesn't miss |
| 48 // OnCacheInitialized() notification. | 60 // OnCacheInitialized() notification. |
| 49 sync_client_->Initialize(); | 61 sync_client_->Initialize(); |
| 50 file_system_->Initialize(); | 62 file_system_->Initialize(); |
| 51 | 63 |
| 52 content::DownloadManager* download_manager = | 64 content::DownloadManager* download_manager = |
| 53 g_browser_process->download_status_updater() ? | 65 g_browser_process->download_status_updater() ? |
| 54 BrowserContext::GetDownloadManager(profile_) : NULL; | 66 BrowserContext::GetDownloadManager(profile_) : NULL; |
| 55 download_observer_->Initialize( | 67 download_observer_->Initialize( |
| 56 uploader_.get(), | 68 uploader_.get(), |
| 57 download_manager, | 69 download_manager, |
| 58 file_system_->GetCacheDirectoryPath( | 70 cache_->GetCacheDirectoryPath( |
| 59 GDataCache::CACHE_TYPE_TMP_DOWNLOADS)); | 71 GDataCache::CACHE_TYPE_TMP_DOWNLOADS)); |
| 60 } | 72 } |
| 61 | 73 |
| 62 void GDataSystemService::Shutdown() { | 74 void GDataSystemService::Shutdown() { |
| 63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 75 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 64 | 76 |
| 65 // Shut down the member objects in the reverse order of creation. | 77 // Shut down the member objects in the reverse order of creation. |
| 66 webapps_registry_.reset(); | 78 webapps_registry_.reset(); |
| 67 sync_client_.reset(); | 79 sync_client_.reset(); |
| 68 download_observer_.reset(); | 80 download_observer_.reset(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 } | 114 } |
| 103 | 115 |
| 104 ProfileKeyedService* GDataSystemServiceFactory::BuildServiceInstanceFor( | 116 ProfileKeyedService* GDataSystemServiceFactory::BuildServiceInstanceFor( |
| 105 Profile* profile) const { | 117 Profile* profile) const { |
| 106 GDataSystemService* service = new GDataSystemService(profile); | 118 GDataSystemService* service = new GDataSystemService(profile); |
| 107 service->Initialize(); | 119 service->Initialize(); |
| 108 return service; | 120 return service; |
| 109 } | 121 } |
| 110 | 122 |
| 111 } // namespace gdata | 123 } // namespace gdata |
| OLD | NEW |