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/drive/drive_file_system.h" | 5 #include "chrome/browser/chromeos/drive/drive_file_system.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/json/json_file_value_serializer.h" | 9 #include "base/json/json_file_value_serializer.h" |
10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/platform_file.h" | 12 #include "base/platform_file.h" |
13 #include "base/prefs/pref_change_registrar.h" | 13 #include "base/prefs/pref_change_registrar.h" |
14 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
15 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" |
16 #include "base/threading/sequenced_worker_pool.h" | 16 #include "base/threading/sequenced_worker_pool.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
18 #include "chrome/browser/chromeos/drive/change_list_loader.h" | 18 #include "chrome/browser/chromeos/drive/change_list_loader.h" |
19 #include "chrome/browser/chromeos/drive/change_list_processor.h" | 19 #include "chrome/browser/chromeos/drive/change_list_processor.h" |
20 #include "chrome/browser/chromeos/drive/drive.pb.h" | 20 #include "chrome/browser/chromeos/drive/drive.pb.h" |
21 #include "chrome/browser/chromeos/drive/drive_cache.h" | 21 #include "chrome/browser/chromeos/drive/drive_cache.h" |
22 #include "chrome/browser/chromeos/drive/drive_file_system_observer.h" | 22 #include "chrome/browser/chromeos/drive/drive_file_system_observer.h" |
23 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" | 23 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" |
24 #include "chrome/browser/chromeos/drive/drive_scheduler.h" | 24 #include "chrome/browser/chromeos/drive/drive_scheduler.h" |
25 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" | 25 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" |
26 #include "chrome/browser/chromeos/drive/search_metadata.h" | 26 #include "chrome/browser/chromeos/drive/search_metadata.h" |
27 #include "chrome/browser/google_apis/drive_api_parser.h" | 27 #include "chrome/browser/google_apis/drive_api_parser.h" |
28 #include "chrome/browser/google_apis/drive_api_util.h" | 28 #include "chrome/browser/google_apis/drive_api_util.h" |
29 #include "chrome/browser/google_apis/drive_service_interface.h" | 29 #include "chrome/browser/google_apis/drive_service_interface.h" |
30 #include "chrome/browser/google_apis/drive_uploader.h" | |
31 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
32 #include "chrome/common/chrome_notification_types.h" | 31 #include "chrome/common/chrome_notification_types.h" |
33 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
34 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
35 #include "content/public/browser/notification_details.h" | 34 #include "content/public/browser/notification_details.h" |
36 | 35 |
37 using content::BrowserThread; | 36 using content::BrowserThread; |
38 | 37 |
39 namespace drive { | 38 namespace drive { |
40 namespace { | 39 namespace { |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 std::string md5; | 212 std::string md5; |
214 }; | 213 }; |
215 | 214 |
216 | 215 |
217 // DriveFileSystem class implementation. | 216 // DriveFileSystem class implementation. |
218 | 217 |
219 DriveFileSystem::DriveFileSystem( | 218 DriveFileSystem::DriveFileSystem( |
220 Profile* profile, | 219 Profile* profile, |
221 DriveCache* cache, | 220 DriveCache* cache, |
222 google_apis::DriveServiceInterface* drive_service, | 221 google_apis::DriveServiceInterface* drive_service, |
223 google_apis::DriveUploaderInterface* uploader, | |
224 DriveWebAppsRegistry* webapps_registry, | 222 DriveWebAppsRegistry* webapps_registry, |
225 DriveResourceMetadata* resource_metadata, | 223 DriveResourceMetadata* resource_metadata, |
226 base::SequencedTaskRunner* blocking_task_runner) | 224 base::SequencedTaskRunner* blocking_task_runner) |
227 : profile_(profile), | 225 : profile_(profile), |
228 cache_(cache), | 226 cache_(cache), |
229 uploader_(uploader), | |
230 drive_service_(drive_service), | 227 drive_service_(drive_service), |
231 webapps_registry_(webapps_registry), | 228 webapps_registry_(webapps_registry), |
232 resource_metadata_(resource_metadata), | 229 resource_metadata_(resource_metadata), |
233 update_timer_(true /* retain_user_task */, true /* is_repeating */), | 230 update_timer_(true /* retain_user_task */, true /* is_repeating */), |
234 last_update_check_error_(DRIVE_FILE_OK), | 231 last_update_check_error_(DRIVE_FILE_OK), |
235 hide_hosted_docs_(false), | 232 hide_hosted_docs_(false), |
236 blocking_task_runner_(blocking_task_runner), | 233 blocking_task_runner_(blocking_task_runner), |
237 scheduler_(new DriveScheduler(profile, drive_service, uploader)), | 234 scheduler_(new DriveScheduler(profile, drive_service)), |
238 polling_interval_sec_(kFastPollingIntervalInSec), | 235 polling_interval_sec_(kFastPollingIntervalInSec), |
239 push_notification_enabled_(false), | 236 push_notification_enabled_(false), |
240 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { | 237 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { |
241 // Should be created from the file browser extension API on UI thread. | 238 // Should be created from the file browser extension API on UI thread. |
242 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 239 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
243 } | 240 } |
244 | 241 |
245 void DriveFileSystem::Reload() { | 242 void DriveFileSystem::Reload() { |
246 resource_metadata_->Reset(base::Bind(&DriveFileSystem::ReloadAfterReset, | 243 resource_metadata_->Reset(base::Bind(&DriveFileSystem::ReloadAfterReset, |
247 weak_ptr_factory_.GetWeakPtr())); | 244 weak_ptr_factory_.GetWeakPtr())); |
248 } | 245 } |
249 | 246 |
250 void DriveFileSystem::Initialize() { | 247 void DriveFileSystem::Initialize() { |
251 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 248 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
252 | 249 |
253 SetupChangeListLoader(); | 250 SetupChangeListLoader(); |
254 | 251 |
255 // Allocate the drive operation handlers. | 252 // Allocate the drive operation handlers. |
256 drive_operations_.Init(scheduler_.get(), | 253 drive_operations_.Init(scheduler_.get(), |
257 this, // DriveFileSystemInterface | 254 this, // DriveFileSystemInterface |
258 cache_, | 255 cache_, |
259 resource_metadata_, | 256 resource_metadata_, |
260 uploader_, | |
261 blocking_task_runner_, | 257 blocking_task_runner_, |
262 this); // OperationObserver | 258 this); // OperationObserver |
263 | 259 |
264 PrefService* pref_service = profile_->GetPrefs(); | 260 PrefService* pref_service = profile_->GetPrefs(); |
265 hide_hosted_docs_ = pref_service->GetBoolean(prefs::kDisableDriveHostedFiles); | 261 hide_hosted_docs_ = pref_service->GetBoolean(prefs::kDisableDriveHostedFiles); |
266 | 262 |
267 scheduler_->Initialize(); | 263 scheduler_->Initialize(); |
268 | 264 |
269 InitializePreferenceObserver(); | 265 InitializePreferenceObserver(); |
270 } | 266 } |
(...skipping 1416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1687 return; | 1683 return; |
1688 } | 1684 } |
1689 | 1685 |
1690 PlatformFileInfoProto entry_file_info; | 1686 PlatformFileInfoProto entry_file_info; |
1691 util::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); | 1687 util::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); |
1692 *entry_proto->mutable_file_info() = entry_file_info; | 1688 *entry_proto->mutable_file_info() = entry_file_info; |
1693 callback.Run(DRIVE_FILE_OK, entry_proto.Pass()); | 1689 callback.Run(DRIVE_FILE_OK, entry_proto.Pass()); |
1694 } | 1690 } |
1695 | 1691 |
1696 } // namespace drive | 1692 } // namespace drive |
OLD | NEW |