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

Side by Side Diff: chrome/browser/chromeos/drive/change_list_loader.cc

Issue 12673003: chromeos: Remove unused DB related code from DriveResourceMetadata (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/drive_resource_metadata.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/drive/change_list_loader.h" 5 #include "chrome/browser/chromeos/drive/change_list_loader.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 15 matching lines...) Expand all
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 drive { 30 namespace drive {
31 31
32 namespace { 32 namespace {
33 33
34 const base::FilePath::CharType kFilesystemProtoFile[] = 34 const base::FilePath::CharType kFilesystemProtoFile[] =
35 FILE_PATH_LITERAL("file_system.pb"); 35 FILE_PATH_LITERAL("file_system.pb");
36 const base::FilePath::CharType kResourceMetadataDBFile[] =
37 FILE_PATH_LITERAL("resource_metadata.db");
38 36
39 // Update the fetch progress UI per every this number of feeds. 37 // Update the fetch progress UI per every this number of feeds.
40 const int kFetchUiUpdateStep = 10; 38 const int kFetchUiUpdateStep = 10;
41 39
42 // Schedule for dumping root file system proto buffers to disk depending its 40 // Schedule for dumping root file system proto buffers to disk depending its
43 // total protobuffer size in MB. 41 // total protobuffer size in MB.
44 typedef struct { 42 typedef struct {
45 double size; 43 double size;
46 int timeout; 44 int timeout;
47 } SerializationTimetable; 45 } SerializationTimetable;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 file_size) { 98 file_size) {
101 LOG(WARNING) << "Drive proto file can't be stored at " 99 LOG(WARNING) << "Drive proto file can't be stored at "
102 << path.value(); 100 << path.value();
103 if (!file_util::Delete(path, true)) { 101 if (!file_util::Delete(path, true)) {
104 LOG(WARNING) << "Drive proto file can't be deleted at " 102 LOG(WARNING) << "Drive proto file can't be deleted at "
105 << path.value(); 103 << path.value();
106 } 104 }
107 } 105 }
108 } 106 }
109 107
110 bool UseLevelDB() {
111 // TODO(achuith): Re-enable this.
112 return false;
113 }
114
115 // Parses a google_apis::ResourceList from |data|. 108 // Parses a google_apis::ResourceList from |data|.
116 scoped_ptr<google_apis::ResourceList> ParseFeedOnBlockingPool( 109 scoped_ptr<google_apis::ResourceList> ParseFeedOnBlockingPool(
117 scoped_ptr<base::Value> data) { 110 scoped_ptr<base::Value> data) {
118 return google_apis::ResourceList::ExtractAndParse(*data); 111 return google_apis::ResourceList::ExtractAndParse(*data);
119 } 112 }
120 113
121 } // namespace 114 } // namespace
122 115
123 // Set of parameters sent to LoadFromServer. 116 // Set of parameters sent to LoadFromServer.
124 // 117 //
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 603
611 // Sets the refreshing flag, so that the caller does not send refresh requests 604 // Sets the refreshing flag, so that the caller does not send refresh requests
612 // in parallel (see DriveFileSystem::LoadFeedIfNeeded). 605 // in parallel (see DriveFileSystem::LoadFeedIfNeeded).
613 // 606 //
614 // Corresponding unset is in ContinueWithInitializedResourceMetadata, where 607 // Corresponding unset is in ContinueWithInitializedResourceMetadata, where
615 // all the control paths reach. 608 // all the control paths reach.
616 refreshing_ = true; 609 refreshing_ = true;
617 610
618 LoadRootFeedParams* params = new LoadRootFeedParams(callback); 611 LoadRootFeedParams* params = new LoadRootFeedParams(callback);
619 base::FilePath path = 612 base::FilePath path =
620 cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_META); 613 cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_META).Append(
621 if (UseLevelDB()) { 614 kFilesystemProtoFile);
622 path = path.Append(kResourceMetadataDBFile); 615 base::PostTaskAndReplyWithResult(
623 resource_metadata_->InitFromDB(path, blocking_task_runner_, 616 BrowserThread::GetBlockingPool(),
624 base::Bind( 617 FROM_HERE,
625 &ChangeListLoader::ContinueWithInitializedResourceMetadata, 618 base::Bind(&LoadProtoOnBlockingPool,
626 weak_ptr_factory_.GetWeakPtr(), 619 path, &params->last_modified, &params->proto),
627 base::Owned(params))); 620 base::Bind(&ChangeListLoader::OnProtoLoaded,
628 } else { 621 weak_ptr_factory_.GetWeakPtr(),
629 path = path.Append(kFilesystemProtoFile); 622 base::Owned(params)));
630 base::PostTaskAndReplyWithResult(
631 BrowserThread::GetBlockingPool(),
632 FROM_HERE,
633 base::Bind(&LoadProtoOnBlockingPool,
634 path, &params->last_modified, &params->proto),
635 base::Bind(&ChangeListLoader::OnProtoLoaded,
636 weak_ptr_factory_.GetWeakPtr(),
637 base::Owned(params)));
638 }
639 } 623 }
640 624
641 void ChangeListLoader::OnProtoLoaded(LoadRootFeedParams* params, 625 void ChangeListLoader::OnProtoLoaded(LoadRootFeedParams* params,
642 DriveFileError error) { 626 DriveFileError error) {
643 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 627 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
644 DCHECK(refreshing_); 628 DCHECK(refreshing_);
645 629
646 // Update directory structure only if everything is OK and we haven't yet 630 // Update directory structure only if everything is OK and we haven't yet
647 // received the feed from the server yet. 631 // received the feed from the server yet.
648 if (error == DRIVE_FILE_OK) { 632 if (error == DRIVE_FILE_OK) {
(...skipping 25 matching lines...) Expand all
674 } 658 }
675 659
676 void ChangeListLoader::SaveFileSystem() { 660 void ChangeListLoader::SaveFileSystem() {
677 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 661 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
678 662
679 if (!ShouldSerializeFileSystemNow(resource_metadata_->serialized_size(), 663 if (!ShouldSerializeFileSystemNow(resource_metadata_->serialized_size(),
680 resource_metadata_->last_serialized())) { 664 resource_metadata_->last_serialized())) {
681 return; 665 return;
682 } 666 }
683 667
684 if (UseLevelDB()) { 668 const base::FilePath path =
685 resource_metadata_->SaveToDB(); 669 cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_META).Append(
686 } else { 670 kFilesystemProtoFile);
687 const base::FilePath path = 671 scoped_ptr<std::string> serialized_proto(new std::string());
688 cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_META).Append( 672 resource_metadata_->SerializeToString(serialized_proto.get());
689 kFilesystemProtoFile); 673 resource_metadata_->set_last_serialized(base::Time::Now());
690 scoped_ptr<std::string> serialized_proto(new std::string()); 674 resource_metadata_->set_serialized_size(serialized_proto->size());
691 resource_metadata_->SerializeToString(serialized_proto.get()); 675 blocking_task_runner_->PostTask(
692 resource_metadata_->set_last_serialized(base::Time::Now()); 676 FROM_HERE,
693 resource_metadata_->set_serialized_size(serialized_proto->size()); 677 base::Bind(&SaveProtoOnBlockingPool, path,
694 blocking_task_runner_->PostTask( 678 base::Passed(&serialized_proto)));
695 FROM_HERE,
696 base::Bind(&SaveProtoOnBlockingPool, path,
697 base::Passed(&serialized_proto)));
698 }
699 } 679 }
700 680
701 void ChangeListLoader::UpdateFromFeed( 681 void ChangeListLoader::UpdateFromFeed(
702 const ScopedVector<google_apis::ResourceList>& feed_list, 682 const ScopedVector<google_apis::ResourceList>& feed_list,
703 bool is_delta_feed, 683 bool is_delta_feed,
704 int64 root_feed_changestamp, 684 int64 root_feed_changestamp,
705 const base::Closure& update_finished_callback) { 685 const base::Closure& update_finished_callback) {
706 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 686 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
707 DCHECK(!update_finished_callback.is_null()); 687 DCHECK(!update_finished_callback.is_null());
708 DVLOG(1) << "Updating directory with a feed"; 688 DVLOG(1) << "Updating directory with a feed";
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 735
756 // Run the callback now that the filesystem is ready. 736 // Run the callback now that the filesystem is ready.
757 load_finished_callback.Run(DRIVE_FILE_OK); 737 load_finished_callback.Run(DRIVE_FILE_OK);
758 738
759 FOR_EACH_OBSERVER(ChangeListLoaderObserver, 739 FOR_EACH_OBSERVER(ChangeListLoaderObserver,
760 observers_, 740 observers_,
761 OnFeedFromServerLoaded()); 741 OnFeedFromServerLoaded());
762 } 742 }
763 743
764 } // namespace drive 744 } // namespace drive
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/drive_resource_metadata.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698