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_file_system.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_file_system.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/json/json_file_value_serializer.h" | 12 #include "base/json/json_file_value_serializer.h" |
| 13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
| 14 #include "base/message_loop_proxy.h" | 14 #include "base/message_loop_proxy.h" |
| 15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "base/platform_file.h" | 16 #include "base/platform_file.h" |
| 17 #include "base/threading/sequenced_worker_pool.h" | 17 #include "base/threading/sequenced_worker_pool.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "chrome/browser/chromeos/gdata/drive_api_parser.h" | 19 #include "chrome/browser/chromeos/gdata/drive_api_parser.h" |
| 20 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" | 20 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" |
| 21 #include "chrome/browser/chromeos/gdata/gdata.pb.h" | 21 #include "chrome/browser/chromeos/gdata/gdata.pb.h" |
| 22 #include "chrome/browser/chromeos/gdata/gdata_documents_service.h" | 22 #include "chrome/browser/chromeos/gdata/gdata_documents_service.h" |
| 23 #include "chrome/browser/chromeos/gdata/gdata_download_observer.h" | 23 #include "chrome/browser/chromeos/gdata/gdata_download_observer.h" |
| 24 #include "chrome/browser/chromeos/gdata/gdata_protocol_handler.h" | 24 #include "chrome/browser/chromeos/gdata/gdata_protocol_handler.h" |
| 25 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" | 25 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" |
| 26 #include "chrome/browser/chromeos/gdata/gdata_util.h" | 26 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
| 27 #include "chrome/browser/chromeos/gdata/stale_cache_files_remover.h" | |
| 27 #include "chrome/browser/prefs/pref_service.h" | 28 #include "chrome/browser/prefs/pref_service.h" |
| 28 #include "chrome/browser/profiles/profile.h" | 29 #include "chrome/browser/profiles/profile.h" |
| 29 #include "chrome/common/chrome_notification_types.h" | 30 #include "chrome/common/chrome_notification_types.h" |
| 30 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
| 31 #include "content/public/browser/browser_thread.h" | 32 #include "content/public/browser/browser_thread.h" |
| 32 #include "content/public/browser/notification_details.h" | 33 #include "content/public/browser/notification_details.h" |
| 33 #include "net/base/mime_util.h" | 34 #include "net/base/mime_util.h" |
| 34 | 35 |
| 35 using content::BrowserThread; | 36 using content::BrowserThread; |
| 36 | 37 |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 530 | 531 |
| 531 documents_service_->Initialize(profile_); | 532 documents_service_->Initialize(profile_); |
| 532 | 533 |
| 533 directory_service_.reset(new GDataDirectoryService); | 534 directory_service_.reset(new GDataDirectoryService); |
| 534 feed_loader_.reset(new GDataWapiFeedLoader(directory_service_.get(), | 535 feed_loader_.reset(new GDataWapiFeedLoader(directory_service_.get(), |
| 535 documents_service_, | 536 documents_service_, |
| 536 webapps_registry_, | 537 webapps_registry_, |
| 537 cache_, | 538 cache_, |
| 538 blocking_task_runner_)); | 539 blocking_task_runner_)); |
| 539 feed_loader_->AddObserver(this); | 540 feed_loader_->AddObserver(this); |
| 541 stale_cache_files_remover_.reset(new StaleCacheFilesRemover(this, cache_)); | |
| 540 | 542 |
| 541 PrefService* pref_service = profile_->GetPrefs(); | 543 PrefService* pref_service = profile_->GetPrefs(); |
| 542 hide_hosted_docs_ = pref_service->GetBoolean(prefs::kDisableGDataHostedFiles); | 544 hide_hosted_docs_ = pref_service->GetBoolean(prefs::kDisableGDataHostedFiles); |
| 543 | 545 |
| 544 InitializePreferenceObserver(); | 546 InitializePreferenceObserver(); |
| 545 } | 547 } |
| 546 | 548 |
| 547 void GDataFileSystem::CheckForUpdates() { | 549 void GDataFileSystem::CheckForUpdates() { |
| 548 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 550 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 549 ContentOrigin initial_origin = directory_service_->origin(); | 551 ContentOrigin initial_origin = directory_service_->origin(); |
| (...skipping 2282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2832 const FindEntryCallback& callback, | 2834 const FindEntryCallback& callback, |
| 2833 GDataFileError error, | 2835 GDataFileError error, |
| 2834 GDataEntry* entry) { | 2836 GDataEntry* entry) { |
| 2835 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2837 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 2836 | 2838 |
| 2837 if (!callback.is_null()) | 2839 if (!callback.is_null()) |
| 2838 callback.Run(error, entry); | 2840 callback.Run(error, entry); |
| 2839 | 2841 |
| 2840 DVLOG(1) << "RunAndNotifyInitialLoadFinished"; | 2842 DVLOG(1) << "RunAndNotifyInitialLoadFinished"; |
| 2841 | 2843 |
| 2844 // Removes stale cache files. | |
| 2845 stale_cache_file_remover_->Start(); | |
|
satorux1
2012/08/14 17:19:37
I suggest you to call this here, but looking at th
yoshiki
2012/08/16 07:39:56
Done.
| |
| 2846 | |
| 2842 // Notify the observers that root directory has been initialized. | 2847 // Notify the observers that root directory has been initialized. |
| 2843 FOR_EACH_OBSERVER(GDataFileSystemInterface::Observer, observers_, | 2848 FOR_EACH_OBSERVER(GDataFileSystemInterface::Observer, observers_, |
| 2844 OnInitialLoadFinished()); | 2849 OnInitialLoadFinished()); |
| 2845 } | 2850 } |
| 2846 | 2851 |
| 2847 GDataFileError GDataFileSystem::AddNewDirectory( | 2852 GDataFileError GDataFileSystem::AddNewDirectory( |
| 2848 const FilePath& directory_path, base::Value* entry_value) { | 2853 const FilePath& directory_path, base::Value* entry_value) { |
| 2849 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2854 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 2850 | 2855 |
| 2851 if (!entry_value) | 2856 if (!entry_value) |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3491 } | 3496 } |
| 3492 | 3497 |
| 3493 PlatformFileInfoProto entry_file_info; | 3498 PlatformFileInfoProto entry_file_info; |
| 3494 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); | 3499 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); |
| 3495 *entry_proto->mutable_file_info() = entry_file_info; | 3500 *entry_proto->mutable_file_info() = entry_file_info; |
| 3496 if (!callback.is_null()) | 3501 if (!callback.is_null()) |
| 3497 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); | 3502 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); |
| 3498 } | 3503 } |
| 3499 | 3504 |
| 3500 } // namespace gdata | 3505 } // namespace gdata |
| OLD | NEW |