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/chromeos/gdata/drive_webapps_registry.h" | 10 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" |
11 #include "chrome/browser/chromeos/gdata/gdata_documents_service.h" | 11 #include "chrome/browser/chromeos/gdata/gdata_documents_service.h" |
12 #include "chrome/browser/chromeos/gdata/gdata_download_observer.h" | 12 #include "chrome/browser/chromeos/gdata/gdata_download_observer.h" |
13 #include "chrome/browser/chromeos/gdata/gdata_file_system.h" | 13 #include "chrome/browser/chromeos/gdata/gdata_file_system.h" |
14 #include "chrome/browser/chromeos/gdata/gdata_file_system_proxy.h" | 14 #include "chrome/browser/chromeos/gdata/gdata_file_system_proxy.h" |
15 #include "chrome/browser/chromeos/gdata/gdata_sync_client.h" | 15 #include "chrome/browser/chromeos/gdata/gdata_sync_client.h" |
16 #include "chrome/browser/chromeos/gdata/gdata_uploader.h" | 16 #include "chrome/browser/chromeos/gdata/gdata_uploader.h" |
17 #include "chrome/browser/chromeos/gdata/gdata_util.h" | 17 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
18 #include "chrome/browser/download/download_service.h" | 18 #include "chrome/browser/download/download_service.h" |
19 #include "chrome/browser/download/download_service_factory.h" | 19 #include "chrome/browser/download/download_service_factory.h" |
20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/profiles/profile_dependency_manager.h" | 21 #include "chrome/browser/profiles/profile_dependency_manager.h" |
22 #include "content/public/browser/browser_context.h" | 22 #include "content/public/browser/browser_context.h" |
23 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
24 #include "webkit/fileapi/file_system_context.h" | 24 #include "webkit/fileapi/file_system_context.h" |
25 #include "webkit/fileapi/file_system_mount_point_provider.h" | 25 #include "webkit/fileapi/file_system_mount_point_provider.h" |
26 | 26 |
27 using content::BrowserContext; | 27 using content::BrowserContext; |
28 using content::BrowserThread; | 28 using content::BrowserThread; |
29 | 29 |
30 namespace gdata { | |
30 namespace { | 31 namespace { |
31 | 32 |
33 const FilePath::CharType kGDataResourceMetadataDBPath[] = | |
34 FILE_PATH_LITERAL("resource_metadata.db"); | |
35 | |
32 // Used in test to setup system service. | 36 // Used in test to setup system service. |
33 gdata::DocumentsServiceInterface* g_test_documents_service = NULL; | 37 gdata::DocumentsServiceInterface* g_test_documents_service = NULL; |
34 const std::string* g_test_cache_root = NULL; | 38 const std::string* g_test_cache_root = NULL; |
35 | 39 |
36 scoped_refptr<base::SequencedTaskRunner> GetTaskRunner( | 40 } // namespace |
37 const base::SequencedWorkerPool::SequenceToken& sequence_token) { | |
38 return BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( | |
39 sequence_token); | |
40 } | |
41 | 41 |
42 } // nemaspace | |
43 | |
44 namespace gdata { | |
45 | |
46 //===================== GDataSystemService ==================================== | |
47 GDataSystemService::GDataSystemService(Profile* profile) | 42 GDataSystemService::GDataSystemService(Profile* profile) |
48 : profile_(profile), | 43 : profile_(profile), |
49 sequence_token_(BrowserThread::GetBlockingPool()->GetSequenceToken()), | 44 sequence_token_(BrowserThread::GetBlockingPool()->GetSequenceToken()), |
50 cache_(NULL) { | 45 cache_(NULL) { |
51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 46 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
52 } | 47 } |
53 | 48 |
54 GDataSystemService::~GDataSystemService() { | 49 GDataSystemService::~GDataSystemService() { |
55 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
56 cache_->DestroyOnUIThread(); | 51 cache_->DestroyOnUIThread(); |
57 } | 52 } |
58 | 53 |
59 void GDataSystemService::Initialize( | 54 void GDataSystemService::Initialize( |
60 DocumentsServiceInterface* documents_service, | 55 DocumentsServiceInterface* documents_service, |
61 const FilePath& cache_root) { | 56 const FilePath& cache_root) { |
62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
63 | 58 |
64 documents_service_.reset(documents_service); | 59 documents_service_.reset(documents_service); |
65 cache_ = GDataCache::CreateGDataCacheOnUIThread( | 60 cache_ = GDataCache::CreateGDataCacheOnUIThread( |
66 cache_root, | 61 cache_root, |
67 GetTaskRunner(sequence_token_)); | 62 GetTaskRunner()); |
68 uploader_.reset(new GDataUploader(docs_service())); | 63 uploader_.reset(new GDataUploader(docs_service())); |
69 webapps_registry_.reset(new DriveWebAppsRegistry); | 64 webapps_registry_.reset(new DriveWebAppsRegistry); |
65 directory_service_.reset(new GDataDirectoryService); | |
70 file_system_.reset(new GDataFileSystem(profile_, | 66 file_system_.reset(new GDataFileSystem(profile_, |
71 cache(), | 67 cache(), |
68 directory_service_.get(), | |
72 docs_service(), | 69 docs_service(), |
73 uploader(), | 70 uploader(), |
74 webapps_registry(), | 71 webapps_registry(), |
75 GetTaskRunner(sequence_token_))); | 72 GetTaskRunner())); |
76 download_observer_.reset(new GDataDownloadObserver(uploader(), | 73 download_observer_.reset(new GDataDownloadObserver(uploader(), |
77 file_system())); | 74 file_system())); |
78 sync_client_.reset(new GDataSyncClient(profile_, file_system(), cache())); | 75 sync_client_.reset(new GDataSyncClient(profile_, file_system(), cache())); |
79 | 76 |
77 #if 1 | |
satorux1
2012/07/24 16:30:34
#if 1 is weird. did you mean to use a command line
| |
78 directory_service_->InitFromDB( | |
79 cache_->GetCacheDirectoryPath(GDataCache::CACHE_TYPE_META).Append( | |
80 kGDataResourceMetadataDBPath), GetTaskRunner()); | |
hashimoto
2012/07/24 08:41:51
Isn't there any chance for |directory_service_| to
| |
81 #endif | |
82 | |
80 sync_client_->Initialize(); | 83 sync_client_->Initialize(); |
81 file_system_->Initialize(); | 84 file_system_->Initialize(); |
82 cache_->RequestInitializeOnUIThread(); | 85 cache_->RequestInitializeOnUIThread(); |
83 | 86 |
84 content::DownloadManager* download_manager = | 87 content::DownloadManager* download_manager = |
85 g_browser_process->download_status_updater() ? | 88 g_browser_process->download_status_updater() ? |
86 BrowserContext::GetDownloadManager(profile_) : NULL; | 89 BrowserContext::GetDownloadManager(profile_) : NULL; |
87 download_observer_->Initialize( | 90 download_observer_->Initialize( |
88 download_manager, | 91 download_manager, |
89 cache_->GetCacheDirectoryPath( | 92 cache_->GetCacheDirectoryPath( |
(...skipping 30 matching lines...) Expand all Loading... | |
120 } | 123 } |
121 | 124 |
122 void GDataSystemService::RemoveDriveMountPoint() { | 125 void GDataSystemService::RemoveDriveMountPoint() { |
123 const FilePath mount_point = gdata::util::GetGDataMountPointPath(); | 126 const FilePath mount_point = gdata::util::GetGDataMountPointPath(); |
124 fileapi::ExternalFileSystemMountPointProvider* provider = | 127 fileapi::ExternalFileSystemMountPointProvider* provider = |
125 BrowserContext::GetFileSystemContext(profile_)->external_provider(); | 128 BrowserContext::GetFileSystemContext(profile_)->external_provider(); |
126 if (provider && provider->HasMountPoint(mount_point)) | 129 if (provider && provider->HasMountPoint(mount_point)) |
127 provider->RemoveMountPoint(mount_point); | 130 provider->RemoveMountPoint(mount_point); |
128 } | 131 } |
129 | 132 |
133 scoped_refptr<base::SequencedTaskRunner> GDataSystemService::GetTaskRunner() { | |
134 return BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( | |
135 sequence_token_); | |
136 } | |
137 | |
130 //===================== GDataSystemServiceFactory ============================= | 138 //===================== GDataSystemServiceFactory ============================= |
131 | 139 |
132 // static | 140 // static |
133 GDataSystemService* GDataSystemServiceFactory::GetForProfile( | 141 GDataSystemService* GDataSystemServiceFactory::GetForProfile( |
134 Profile* profile) { | 142 Profile* profile) { |
135 return static_cast<GDataSystemService*>( | 143 return static_cast<GDataSystemService*>( |
136 GetInstance()->GetServiceForProfile(profile, true)); | 144 GetInstance()->GetServiceForProfile(profile, true)); |
137 } | 145 } |
138 | 146 |
139 // static | 147 // static |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 g_test_cache_root ? FilePath(*g_test_cache_root) : | 194 g_test_cache_root ? FilePath(*g_test_cache_root) : |
187 GDataCache::GetCacheRootPath(profile); | 195 GDataCache::GetCacheRootPath(profile); |
188 delete g_test_cache_root; | 196 delete g_test_cache_root; |
189 g_test_cache_root = NULL; | 197 g_test_cache_root = NULL; |
190 | 198 |
191 service->Initialize(documents_service, cache_root); | 199 service->Initialize(documents_service, cache_root); |
192 return service; | 200 return service; |
193 } | 201 } |
194 | 202 |
195 } // namespace gdata | 203 } // namespace gdata |
OLD | NEW |