Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(546)

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_wapi_feed_loader.cc

Issue 10877005: Rename GDataCache* to DriveCache* (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_wapi_feed_loader.h" 5 #include "chrome/browser/chromeos/gdata/gdata_wapi_feed_loader.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/format_macros.h" 11 #include "base/format_macros.h"
12 #include "base/json/json_reader.h" 12 #include "base/json/json_reader.h"
13 #include "base/json/json_writer.h" 13 #include "base/json/json_writer.h"
14 #include "base/message_loop.h" 14 #include "base/message_loop.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/stringprintf.h" 16 #include "base/stringprintf.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_cache.h"
20 #include "chrome/browser/chromeos/gdata/drive_service_interface.h" 21 #include "chrome/browser/chromeos/gdata/drive_service_interface.h"
21 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" 22 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h"
22 #include "chrome/browser/chromeos/gdata/gdata_cache.h"
23 #include "chrome/browser/chromeos/gdata/gdata_util.h" 23 #include "chrome/browser/chromeos/gdata/gdata_util.h"
24 #include "chrome/browser/chromeos/gdata/gdata_wapi_feed_processor.h" 24 #include "chrome/browser/chromeos/gdata/gdata_wapi_feed_processor.h"
25 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
26 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
27 27
28 using content::BrowserThread; 28 using content::BrowserThread;
29 29
30 namespace gdata { 30 namespace gdata {
31 31
32 namespace { 32 namespace {
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 // Time elapsed since the feed fetching was started. 233 // Time elapsed since the feed fetching was started.
234 base::TimeDelta feed_fetching_elapsed_time; 234 base::TimeDelta feed_fetching_elapsed_time;
235 235
236 base::WeakPtrFactory<GetDocumentsUiState> weak_ptr_factory; 236 base::WeakPtrFactory<GetDocumentsUiState> weak_ptr_factory;
237 }; 237 };
238 238
239 GDataWapiFeedLoader::GDataWapiFeedLoader( 239 GDataWapiFeedLoader::GDataWapiFeedLoader(
240 DriveResourceMetadata* resource_metadata, 240 DriveResourceMetadata* resource_metadata,
241 DriveServiceInterface* drive_service, 241 DriveServiceInterface* drive_service,
242 DriveWebAppsRegistryInterface* webapps_registry, 242 DriveWebAppsRegistryInterface* webapps_registry,
243 GDataCache* cache, 243 DriveCache* cache,
244 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) 244 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner)
245 : resource_metadata_(resource_metadata), 245 : resource_metadata_(resource_metadata),
246 drive_service_(drive_service), 246 drive_service_(drive_service),
247 webapps_registry_(webapps_registry), 247 webapps_registry_(webapps_registry),
248 cache_(cache), 248 cache_(cache),
249 blocking_task_runner_(blocking_task_runner), 249 blocking_task_runner_(blocking_task_runner),
250 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 250 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
251 } 251 }
252 252
253 GDataWapiFeedLoader::~GDataWapiFeedLoader() { 253 GDataWapiFeedLoader::~GDataWapiFeedLoader() {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 LoadFromServer(params); 318 LoadFromServer(params);
319 return; 319 return;
320 } 320 }
321 321
322 scoped_ptr<AccountMetadataFeed> account_metadata; 322 scoped_ptr<AccountMetadataFeed> account_metadata;
323 if (feed_data.get()) { 323 if (feed_data.get()) {
324 account_metadata = AccountMetadataFeed::CreateFrom(*feed_data); 324 account_metadata = AccountMetadataFeed::CreateFrom(*feed_data);
325 #ifndef NDEBUG 325 #ifndef NDEBUG
326 // Save account metadata feed for analysis. 326 // Save account metadata feed for analysis.
327 const FilePath path = 327 const FilePath path =
328 cache_->GetCacheDirectoryPath(GDataCache::CACHE_TYPE_META).Append( 328 cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_META).Append(
329 kAccountMetadataFile); 329 kAccountMetadataFile);
330 util::PostBlockingPoolSequencedTask( 330 util::PostBlockingPoolSequencedTask(
331 FROM_HERE, 331 FROM_HERE,
332 blocking_task_runner_, 332 blocking_task_runner_,
333 base::Bind(&SaveFeedOnBlockingPoolForDebugging, 333 base::Bind(&SaveFeedOnBlockingPoolForDebugging,
334 path, base::Passed(&feed_data))); 334 path, base::Passed(&feed_data)));
335 #endif 335 #endif
336 } 336 }
337 337
338 if (!account_metadata.get()) { 338 if (!account_metadata.get()) {
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 #ifndef NDEBUG 589 #ifndef NDEBUG
590 // Save initial root feed for analysis. 590 // Save initial root feed for analysis.
591 std::string file_name = 591 std::string file_name =
592 base::StringPrintf("DEBUG_feed_%" PRId64 ".json", 592 base::StringPrintf("DEBUG_feed_%" PRId64 ".json",
593 params->start_changestamp); 593 params->start_changestamp);
594 util::PostBlockingPoolSequencedTask( 594 util::PostBlockingPoolSequencedTask(
595 FROM_HERE, 595 FROM_HERE,
596 blocking_task_runner_, 596 blocking_task_runner_,
597 base::Bind(&SaveFeedOnBlockingPoolForDebugging, 597 base::Bind(&SaveFeedOnBlockingPoolForDebugging,
598 cache_->GetCacheDirectoryPath( 598 cache_->GetCacheDirectoryPath(
599 GDataCache::CACHE_TYPE_META).Append(file_name), 599 DriveCache::CACHE_TYPE_META).Append(file_name),
600 base::Passed(&data))); 600 base::Passed(&data)));
601 #endif 601 #endif
602 602
603 // Add the current feed to the list of collected feeds for this directory. 603 // Add the current feed to the list of collected feeds for this directory.
604 params->feed_list->push_back(current_feed.release()); 604 params->feed_list->push_back(current_feed.release());
605 605
606 // Compute and notify the number of entries fetched so far. 606 // Compute and notify the number of entries fetched so far.
607 int num_accumulated_entries = 0; 607 int num_accumulated_entries = 0;
608 for (size_t i = 0; i < params->feed_list->size(); ++i) 608 for (size_t i = 0; i < params->feed_list->size(); ++i)
609 num_accumulated_entries += params->feed_list->at(i)->entries().size(); 609 num_accumulated_entries += params->feed_list->at(i)->entries().size();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 #ifndef NDEBUG 702 #ifndef NDEBUG
703 // Save initial root feed for analysis. 703 // Save initial root feed for analysis.
704 std::string file_name = 704 std::string file_name =
705 base::StringPrintf("DEBUG_changelist_%" PRId64 ".json", 705 base::StringPrintf("DEBUG_changelist_%" PRId64 ".json",
706 params->start_changestamp); 706 params->start_changestamp);
707 util::PostBlockingPoolSequencedTask( 707 util::PostBlockingPoolSequencedTask(
708 FROM_HERE, 708 FROM_HERE,
709 blocking_task_runner_, 709 blocking_task_runner_,
710 base::Bind(&SaveFeedOnBlockingPoolForDebugging, 710 base::Bind(&SaveFeedOnBlockingPoolForDebugging,
711 cache_->GetCacheDirectoryPath( 711 cache_->GetCacheDirectoryPath(
712 GDataCache::CACHE_TYPE_META).Append(file_name), 712 DriveCache::CACHE_TYPE_META).Append(file_name),
713 base::Passed(&data))); 713 base::Passed(&data)));
714 #endif 714 #endif
715 715
716 // Add the current feed to the list of collected feeds for this directory. 716 // Add the current feed to the list of collected feeds for this directory.
717 scoped_ptr<DocumentFeed> feed = 717 scoped_ptr<DocumentFeed> feed =
718 DocumentFeed::CreateFromChangeList(*current_feed); 718 DocumentFeed::CreateFromChangeList(*current_feed);
719 params->feed_list->push_back(feed.release()); 719 params->feed_list->push_back(feed.release());
720 720
721 // Compute and notify the number of entries fetched so far. 721 // Compute and notify the number of entries fetched so far.
722 int num_accumulated_entries = 0; 722 int num_accumulated_entries = 0;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 } 816 }
817 } 817 }
818 818
819 void GDataWapiFeedLoader::LoadFromCache( 819 void GDataWapiFeedLoader::LoadFromCache(
820 bool should_load_from_server, 820 bool should_load_from_server,
821 const FileOperationCallback& callback) { 821 const FileOperationCallback& callback) {
822 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 822 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
823 823
824 LoadRootFeedParams* params = new LoadRootFeedParams(should_load_from_server, 824 LoadRootFeedParams* params = new LoadRootFeedParams(should_load_from_server,
825 callback); 825 callback);
826 FilePath path = cache_->GetCacheDirectoryPath(GDataCache::CACHE_TYPE_META); 826 FilePath path = cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_META);
827 if (UseLevelDB()) { 827 if (UseLevelDB()) {
828 path = path.Append(kResourceMetadataDBFile); 828 path = path.Append(kResourceMetadataDBFile);
829 resource_metadata_->InitFromDB(path, blocking_task_runner_, 829 resource_metadata_->InitFromDB(path, blocking_task_runner_,
830 base::Bind( 830 base::Bind(
831 &GDataWapiFeedLoader::ContinueWithInitializedDirectoryService, 831 &GDataWapiFeedLoader::ContinueWithInitializedDirectoryService,
832 weak_ptr_factory_.GetWeakPtr(), 832 weak_ptr_factory_.GetWeakPtr(),
833 base::Owned(params))); 833 base::Owned(params)));
834 } else { 834 } else {
835 path = path.Append(kFilesystemProtoFile); 835 path = path.Append(kFilesystemProtoFile);
836 BrowserThread::GetBlockingPool()->PostTaskAndReply(FROM_HERE, 836 BrowserThread::GetBlockingPool()->PostTaskAndReply(FROM_HERE,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 913
914 if (!ShouldSerializeFileSystemNow(resource_metadata_->serialized_size(), 914 if (!ShouldSerializeFileSystemNow(resource_metadata_->serialized_size(),
915 resource_metadata_->last_serialized())) { 915 resource_metadata_->last_serialized())) {
916 return; 916 return;
917 } 917 }
918 918
919 if (UseLevelDB()) { 919 if (UseLevelDB()) {
920 resource_metadata_->SaveToDB(); 920 resource_metadata_->SaveToDB();
921 } else { 921 } else {
922 const FilePath path = 922 const FilePath path =
923 cache_->GetCacheDirectoryPath(GDataCache::CACHE_TYPE_META).Append( 923 cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_META).Append(
924 kFilesystemProtoFile); 924 kFilesystemProtoFile);
925 scoped_ptr<std::string> serialized_proto(new std::string()); 925 scoped_ptr<std::string> serialized_proto(new std::string());
926 resource_metadata_->SerializeToString(serialized_proto.get()); 926 resource_metadata_->SerializeToString(serialized_proto.get());
927 resource_metadata_->set_last_serialized(base::Time::Now()); 927 resource_metadata_->set_last_serialized(base::Time::Now());
928 resource_metadata_->set_serialized_size(serialized_proto->size()); 928 resource_metadata_->set_serialized_size(serialized_proto->size());
929 util::PostBlockingPoolSequencedTask( 929 util::PostBlockingPoolSequencedTask(
930 FROM_HERE, 930 FROM_HERE,
931 blocking_task_runner_, 931 blocking_task_runner_,
932 base::Bind(&SaveProtoOnBlockingPool, path, 932 base::Bind(&SaveProtoOnBlockingPool, path,
933 base::Passed(serialized_proto.Pass()))); 933 base::Passed(serialized_proto.Pass())));
(...skipping 24 matching lines...) Expand all
958 dir_iter != changed_dirs.end(); ++dir_iter) { 958 dir_iter != changed_dirs.end(); ++dir_iter) {
959 FOR_EACH_OBSERVER(Observer, observers_, 959 FOR_EACH_OBSERVER(Observer, observers_,
960 OnDirectoryChanged(*dir_iter)); 960 OnDirectoryChanged(*dir_iter));
961 } 961 }
962 } 962 }
963 963
964 return error; 964 return error;
965 } 965 }
966 966
967 } // namespace gdata 967 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_wapi_feed_loader.h ('k') | chrome/browser/chromeos/gdata/mock_drive_cache_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698