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

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

Issue 10800092: Database support for GDataDirectoryService. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: 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_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/command_line.h"
11 #include "base/file_util.h" 12 #include "base/file_util.h"
12 #include "base/json/json_file_value_serializer.h" 13 #include "base/json/json_file_value_serializer.h"
13 #include "base/json/json_reader.h" 14 #include "base/json/json_reader.h"
14 #include "base/json/json_writer.h" 15 #include "base/json/json_writer.h"
15 #include "base/message_loop.h" 16 #include "base/message_loop.h"
16 #include "base/message_loop_proxy.h" 17 #include "base/message_loop_proxy.h"
17 #include "base/metrics/histogram.h" 18 #include "base/metrics/histogram.h"
18 #include "base/platform_file.h" 19 #include "base/platform_file.h"
19 #include "base/threading/sequenced_worker_pool.h" 20 #include "base/threading/sequenced_worker_pool.h"
20 #include "base/values.h" 21 #include "base/values.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.pb.h" 23 #include "chrome/browser/chromeos/gdata/gdata.pb.h"
23 #include "chrome/browser/chromeos/gdata/gdata_documents_service.h" 24 #include "chrome/browser/chromeos/gdata/gdata_documents_service.h"
24 #include "chrome/browser/chromeos/gdata/gdata_download_observer.h" 25 #include "chrome/browser/chromeos/gdata/gdata_download_observer.h"
25 #include "chrome/browser/chromeos/gdata/gdata_protocol_handler.h" 26 #include "chrome/browser/chromeos/gdata/gdata_protocol_handler.h"
26 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" 27 #include "chrome/browser/chromeos/gdata/gdata_system_service.h"
27 #include "chrome/browser/chromeos/gdata/gdata_util.h" 28 #include "chrome/browser/chromeos/gdata/gdata_util.h"
28 #include "chrome/browser/prefs/pref_service.h" 29 #include "chrome/browser/prefs/pref_service.h"
29 #include "chrome/browser/profiles/profile.h" 30 #include "chrome/browser/profiles/profile.h"
31 #include "chrome/common/chrome_switches.h"
30 #include "chrome/common/chrome_notification_types.h" 32 #include "chrome/common/chrome_notification_types.h"
31 #include "chrome/common/pref_names.h" 33 #include "chrome/common/pref_names.h"
32 #include "content/public/browser/browser_thread.h" 34 #include "content/public/browser/browser_thread.h"
33 #include "content/public/browser/notification_details.h" 35 #include "content/public/browser/notification_details.h"
34 #include "net/base/mime_util.h" 36 #include "net/base/mime_util.h"
35 37
36 using content::BrowserThread; 38 using content::BrowserThread;
37 39
38 namespace gdata { 40 namespace gdata {
39 namespace { 41 namespace {
40 42
41 const char kMimeTypeJson[] = "application/json"; 43 const char kMimeTypeJson[] = "application/json";
42 const char kMimeTypeOctetStream[] = "application/octet-stream"; 44 const char kMimeTypeOctetStream[] = "application/octet-stream";
43 45
44 const FilePath::CharType kAccountMetadataFile[] = 46 const FilePath::CharType kAccountMetadataFile[] =
45 FILE_PATH_LITERAL("account_metadata.json"); 47 FILE_PATH_LITERAL("account_metadata.json");
46 const FilePath::CharType kFilesystemProtoFile[] = 48 const FilePath::CharType kFilesystemProtoFile[] =
47 FILE_PATH_LITERAL("file_system.pb"); 49 FILE_PATH_LITERAL("file_system.pb");
50 const FilePath::CharType kResourceMetadataDBFile[] =
51 FILE_PATH_LITERAL("resource_metadata.db");
48 52
49 const char kEmptyFilePath[] = "/dev/null"; 53 const char kEmptyFilePath[] = "/dev/null";
50 54
51 // GData update check interval (in seconds). 55 // GData update check interval (in seconds).
52 #ifndef NDEBUG 56 #ifndef NDEBUG
53 const int kGDataUpdateCheckIntervalInSec = 5; 57 const int kGDataUpdateCheckIntervalInSec = 5;
54 #else 58 #else
55 const int kGDataUpdateCheckIntervalInSec = 60; 59 const int kGDataUpdateCheckIntervalInSec = 60;
56 #endif 60 #endif
57 61
(...skipping 10 matching lines...) Expand all
68 {-1, 1}, // Any size, dump if older than 1 minute. 72 {-1, 1}, // Any size, dump if older than 1 minute.
69 #else 73 #else
70 {0.5, 0}, // Less than 0.5MB, dump immediately. 74 {0.5, 0}, // Less than 0.5MB, dump immediately.
71 {1.0, 15}, // Less than 1.0MB, dump after 15 minutes. 75 {1.0, 15}, // Less than 1.0MB, dump after 15 minutes.
72 {2.0, 30}, 76 {2.0, 30},
73 {4.0, 60}, 77 {4.0, 60},
74 {-1, 120}, // Any size, dump if older than 120 minutes. 78 {-1, 120}, // Any size, dump if older than 120 minutes.
75 #endif 79 #endif
76 }; 80 };
77 81
78 // Defines set of parameters sent to callback OnProtoLoaded().
79 struct LoadRootFeedParams {
80 LoadRootFeedParams(
81 FilePath search_file_path,
82 bool should_load_from_server,
83 const FindEntryCallback& callback)
84 : search_file_path(search_file_path),
85 should_load_from_server(should_load_from_server),
86 load_error(GDATA_FILE_OK),
87 callback(callback) {
88 }
89 ~LoadRootFeedParams() {
90 }
91
92 FilePath search_file_path;
93 bool should_load_from_server;
94 std::string proto;
95 GDataFileError load_error;
96 base::Time last_modified;
97 const FindEntryCallback callback;
98 };
99
100 // Returns true if file system is due to be serialized on disk based on it 82 // Returns true if file system is due to be serialized on disk based on it
101 // |serialized_size| and |last_serialized| timestamp. 83 // |serialized_size| and |last_serialized| timestamp.
102 bool ShouldSerializeFileSystemNow(size_t serialized_size, 84 bool ShouldSerializeFileSystemNow(size_t serialized_size,
103 const base::Time& last_serialized) { 85 const base::Time& last_serialized) {
104 const double size_in_mb = serialized_size / 1048576.0; 86 const double size_in_mb = serialized_size / 1048576.0;
105 const int last_proto_dump_in_min = 87 const int last_proto_dump_in_min =
106 (base::Time::Now() - last_serialized).InMinutes(); 88 (base::Time::Now() - last_serialized).InMinutes();
107 for (size_t i = 0; i < arraysize(kSerializeTimetable); i++) { 89 for (size_t i = 0; i < arraysize(kSerializeTimetable); i++) {
108 if ((size_in_mb < kSerializeTimetable[i].size || 90 if ((size_in_mb < kSerializeTimetable[i].size ||
109 kSerializeTimetable[i].size == -1) && 91 kSerializeTimetable[i].size == -1) &&
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 LOG(WARNING) << "GData metadata file can't be stored at " 245 LOG(WARNING) << "GData metadata file can't be stored at "
264 << file_path.value(); 246 << file_path.value();
265 if (!file_util::Delete(file_path, true)) { 247 if (!file_util::Delete(file_path, true)) {
266 LOG(WARNING) << "GData metadata file can't be deleted at " 248 LOG(WARNING) << "GData metadata file can't be deleted at "
267 << file_path.value(); 249 << file_path.value();
268 return; 250 return;
269 } 251 }
270 } 252 }
271 } 253 }
272 254
255 bool UseLevelDB() {
256 return CommandLine::ForCurrentProcess()->HasSwitch(
257 switches::kUseLevelDBForGData);
258 }
259
273 // Gets the file size of |local_file|. 260 // Gets the file size of |local_file|.
274 void GetLocalFileSizeOnBlockingPool(const FilePath& local_file, 261 void GetLocalFileSizeOnBlockingPool(const FilePath& local_file,
275 GDataFileError* error, 262 GDataFileError* error,
276 int64* file_size) { 263 int64* file_size) {
277 DCHECK(error); 264 DCHECK(error);
278 DCHECK(file_size); 265 DCHECK(file_size);
279 266
280 *file_size = 0; 267 *file_size = 0;
281 *error = file_util::GetFileSize(local_file, file_size) ? 268 *error = file_util::GetFileSize(local_file, file_size) ?
282 GDATA_FILE_OK : 269 GDATA_FILE_OK :
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 directory_service_->FindEntryByPathAndRunSync(search_file_path, callback); 930 directory_service_->FindEntryByPathAndRunSync(search_file_path, callback);
944 } 931 }
945 932
946 void GDataWapiFeedLoader::ReloadFromServerIfNeeded( 933 void GDataWapiFeedLoader::ReloadFromServerIfNeeded(
947 ContentOrigin initial_origin, 934 ContentOrigin initial_origin,
948 int local_changestamp, 935 int local_changestamp,
949 const FilePath& search_file_path, 936 const FilePath& search_file_path,
950 const FindEntryCallback& callback) { 937 const FindEntryCallback& callback) {
951 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 938 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
952 939
940 DVLOG(1) << "ReloadFeedFromServerIfNeeded local_changestamp="
941 << local_changestamp << ", initial_origin=" << initial_origin;
942
953 // First fetch the latest changestamp to see if there were any new changes 943 // First fetch the latest changestamp to see if there were any new changes
954 // there at all. 944 // there at all.
955 documents_service_->GetAccountMetadata( 945 documents_service_->GetAccountMetadata(
956 base::Bind(&GDataWapiFeedLoader::OnGetAccountMetadata, 946 base::Bind(&GDataWapiFeedLoader::OnGetAccountMetadata,
957 weak_ptr_factory_.GetWeakPtr(), 947 weak_ptr_factory_.GetWeakPtr(),
958 initial_origin, 948 initial_origin,
959 local_changestamp, 949 local_changestamp,
960 search_file_path, 950 search_file_path,
961 callback)); 951 callback));
962 } 952 }
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 params->root_feed_changestamp); 1095 params->root_feed_changestamp);
1106 1096
1107 if (error != GDATA_FILE_OK) { 1097 if (error != GDATA_FILE_OK) {
1108 if (!params->callback.is_null()) 1098 if (!params->callback.is_null())
1109 params->callback.Run(error, NULL); 1099 params->callback.Run(error, NULL);
1110 1100
1111 return; 1101 return;
1112 } 1102 }
1113 1103
1114 // Save file system metadata to disk. 1104 // Save file system metadata to disk.
1115 SaveFileSystemAsProto(); 1105 SaveFileSystem();
1116 1106
1117 // If we had someone to report this too, then this retrieval was done in a 1107 // If we had someone to report this too, then this retrieval was done in a
1118 // context of search... so continue search. 1108 // context of search... so continue search.
1119 if (!params->callback.is_null()) { 1109 if (!params->callback.is_null()) {
1120 directory_service_->FindEntryByPathAndRunSync(params->search_file_path, 1110 directory_service_->FindEntryByPathAndRunSync(params->search_file_path,
1121 params->callback); 1111 params->callback);
1122 } 1112 }
1123 1113
1124 FOR_EACH_OBSERVER(Observer, observers_, OnFeedFromServerLoaded()); 1114 FOR_EACH_OBSERVER(Observer, observers_, OnFeedFromServerLoaded());
1125 } 1115 }
(...skipping 1745 matching lines...) Expand 10 before | Expand all | Expand 10 after
2871 if (!callback.is_null()) 2861 if (!callback.is_null())
2872 callback.Run(params, error); 2862 callback.Run(params, error);
2873 } 2863 }
2874 2864
2875 void GDataWapiFeedLoader::LoadFromCache( 2865 void GDataWapiFeedLoader::LoadFromCache(
2876 bool should_load_from_server, 2866 bool should_load_from_server,
2877 const FilePath& search_file_path, 2867 const FilePath& search_file_path,
2878 const FindEntryCallback& callback) { 2868 const FindEntryCallback& callback) {
2879 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2869 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2880 2870
2881 const FilePath path =
2882 cache_->GetCacheDirectoryPath(GDataCache::CACHE_TYPE_META).Append(
2883 kFilesystemProtoFile);
2884 LoadRootFeedParams* params = new LoadRootFeedParams(search_file_path, 2871 LoadRootFeedParams* params = new LoadRootFeedParams(search_file_path,
2885 should_load_from_server, 2872 should_load_from_server,
2886 callback); 2873 callback);
2887 BrowserThread::GetBlockingPool()->PostTaskAndReply(FROM_HERE, 2874 FilePath path = cache_->GetCacheDirectoryPath(GDataCache::CACHE_TYPE_META);
2888 base::Bind(&LoadProtoOnBlockingPool, path, params), 2875 if (UseLevelDB()) {
2889 base::Bind(&GDataWapiFeedLoader::OnProtoLoaded, 2876 path = path.Append(kResourceMetadataDBFile);
2890 weak_ptr_factory_.GetWeakPtr(), 2877 directory_service_->InitFromDB(path, blocking_task_runner_,
2891 base::Owned(params))); 2878 &params->load_error, base::Bind(
satorux1 2012/08/03 22:17:26 I think I was confused about this |load_error| par
achuithb 2012/08/03 22:25:58 because? The suspense is killing me ;) We need to
satorux1 2012/08/03 22:33:30 oops, here's what I was thinking: Instead of pass
achuithb 2012/08/03 23:27:35 Done.
2879 &GDataWapiFeedLoader::ContinueWithInitializedDirectoryService,
2880 weak_ptr_factory_.GetWeakPtr(),
2881 base::Owned(params)));
2882 } else {
2883 path = path.Append(kFilesystemProtoFile);
2884 BrowserThread::GetBlockingPool()->PostTaskAndReply(FROM_HERE,
2885 base::Bind(&LoadProtoOnBlockingPool, path, params),
2886 base::Bind(&GDataWapiFeedLoader::OnProtoLoaded,
2887 weak_ptr_factory_.GetWeakPtr(),
2888 base::Owned(params)));
2889 }
2892 } 2890 }
2893 2891
2894 void GDataFileSystem::OnDirectoryChanged(const FilePath& directory_path) { 2892 void GDataFileSystem::OnDirectoryChanged(const FilePath& directory_path) {
2895 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2893 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2896 2894
2897 FOR_EACH_OBSERVER(GDataFileSystemInterface::Observer, observers_, 2895 FOR_EACH_OBSERVER(GDataFileSystemInterface::Observer, observers_,
2898 OnDirectoryChanged(directory_path)); 2896 OnDirectoryChanged(directory_path));
2899 } 2897 }
2900 2898
2901 void GDataFileSystem::OnDocumentFeedFetched(int num_accumulated_entries) { 2899 void GDataFileSystem::OnDocumentFeedFetched(int num_accumulated_entries) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2933 root_feed_changestamp); 2931 root_feed_changestamp);
2934 } 2932 }
2935 2933
2936 void GDataWapiFeedLoader::OnProtoLoaded(LoadRootFeedParams* params) { 2934 void GDataWapiFeedLoader::OnProtoLoaded(LoadRootFeedParams* params) {
2937 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2935 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2938 2936
2939 // If we have already received updates from the server, bail out. 2937 // If we have already received updates from the server, bail out.
2940 if (directory_service_->origin() == FROM_SERVER) 2938 if (directory_service_->origin() == FROM_SERVER)
2941 return; 2939 return;
2942 2940
2943 int local_changestamp = 0;
2944 // Update directory structure only if everything is OK and we haven't yet 2941 // Update directory structure only if everything is OK and we haven't yet
2945 // received the feed from the server yet. 2942 // received the feed from the server yet.
2946 if (params->load_error == GDATA_FILE_OK) { 2943 if (params->load_error == GDATA_FILE_OK) {
2947 DVLOG(1) << "ParseFromString"; 2944 DVLOG(1) << "ParseFromString";
2948 if (directory_service_->ParseFromString(params->proto)) { 2945 if (directory_service_->ParseFromString(params->proto)) {
2949 directory_service_->set_last_serialized(params->last_modified); 2946 directory_service_->set_last_serialized(params->last_modified);
2950 directory_service_->set_serialized_size(params->proto.size()); 2947 directory_service_->set_serialized_size(params->proto.size());
2951 local_changestamp = directory_service_->largest_changestamp();
2952 } else { 2948 } else {
2953 params->load_error = GDATA_FILE_ERROR_FAILED; 2949 params->load_error = GDATA_FILE_ERROR_FAILED;
2954 LOG(WARNING) << "Parse of cached proto file failed"; 2950 LOG(WARNING) << "Parse of cached proto file failed";
2955 } 2951 }
2956 } 2952 }
2957 2953
2954 ContinueWithInitializedDirectoryService(params);
2955 }
2956
2957 void GDataWapiFeedLoader::ContinueWithInitializedDirectoryService(
2958 LoadRootFeedParams* params) {
2959 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2960
2961 DVLOG(1) << "Time elapsed to load directory service from disk="
2962 << (base::Time::Now() - params->load_start_time).InMilliseconds()
2963 << " milliseconds";
2964
2958 FindEntryCallback callback = params->callback; 2965 FindEntryCallback callback = params->callback;
2959 // If we got feed content from cache, try search over it. 2966 // If we got feed content from cache, try search over it.
2960 if (params->load_error == GDATA_FILE_OK && !callback.is_null()) { 2967 if (params->load_error == GDATA_FILE_OK && !callback.is_null()) {
2961 // Continue file content search operation if the delegate hasn't terminated 2968 // Continue file content search operation if the delegate hasn't terminated
2962 // this search branch already. 2969 // this search branch already.
2963 directory_service_->FindEntryByPathAndRunSync(params->search_file_path, 2970 directory_service_->FindEntryByPathAndRunSync(params->search_file_path,
2964 callback); 2971 callback);
2965 callback.Reset(); 2972 callback.Reset();
2966 } 2973 }
2967 2974
(...skipping 10 matching lines...) Expand all
2978 // If directory content is already initialized, restore content origin 2985 // If directory content is already initialized, restore content origin
2979 // to FROM_CACHE in case of failure. 2986 // to FROM_CACHE in case of failure.
2980 initial_origin = FROM_CACHE; 2987 initial_origin = FROM_CACHE;
2981 directory_service_->set_origin(REFRESHING); 2988 directory_service_->set_origin(REFRESHING);
2982 } 2989 }
2983 2990
2984 // Kick of the retrieval of the feed from server. If we have previously 2991 // Kick of the retrieval of the feed from server. If we have previously
2985 // |reported| to the original callback, then we just need to refresh the 2992 // |reported| to the original callback, then we just need to refresh the
2986 // content without continuing search upon operation completion. 2993 // content without continuing search upon operation completion.
2987 ReloadFromServerIfNeeded(initial_origin, 2994 ReloadFromServerIfNeeded(initial_origin,
2988 local_changestamp, 2995 directory_service_->largest_changestamp(),
2989 params->search_file_path, 2996 params->search_file_path,
2990 callback); 2997 callback);
2991 } 2998 }
2992 2999
2993 void GDataWapiFeedLoader::SaveFileSystemAsProto() { 3000 void GDataWapiFeedLoader::SaveFileSystem() {
2994 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 3001 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2995 3002
2996 DVLOG(1) << "SaveFileSystemAsProto";
2997
2998 if (!ShouldSerializeFileSystemNow(directory_service_->serialized_size(), 3003 if (!ShouldSerializeFileSystemNow(directory_service_->serialized_size(),
2999 directory_service_->last_serialized())) { 3004 directory_service_->last_serialized())) {
3000 return; 3005 return;
3001 } 3006 }
3002 3007
3003 const FilePath path = 3008 if (UseLevelDB()) {
3004 cache_->GetCacheDirectoryPath(GDataCache::CACHE_TYPE_META).Append( 3009 directory_service_->SaveToDB();
3005 kFilesystemProtoFile); 3010 } else {
3006 scoped_ptr<std::string> serialized_proto(new std::string()); 3011 const FilePath path =
3007 directory_service_->SerializeToString(serialized_proto.get()); 3012 cache_->GetCacheDirectoryPath(GDataCache::CACHE_TYPE_META).Append(
3008 directory_service_->set_last_serialized(base::Time::Now()); 3013 kFilesystemProtoFile);
3009 directory_service_->set_serialized_size(serialized_proto->size()); 3014 scoped_ptr<std::string> serialized_proto(new std::string());
3010 PostBlockingPoolSequencedTask( 3015 directory_service_->SerializeToString(serialized_proto.get());
3011 FROM_HERE, 3016 directory_service_->set_last_serialized(base::Time::Now());
3012 blocking_task_runner_, 3017 directory_service_->set_serialized_size(serialized_proto->size());
3013 base::Bind(&SaveProtoOnBlockingPool, path, 3018 PostBlockingPoolSequencedTask(
3014 base::Passed(serialized_proto.Pass()))); 3019 FROM_HERE,
3020 blocking_task_runner_,
3021 base::Bind(&SaveProtoOnBlockingPool, path,
3022 base::Passed(serialized_proto.Pass())));
3023 }
3015 } 3024 }
3016 3025
3017 void GDataFileSystem::OnFilePathUpdated(const FileOperationCallback& callback, 3026 void GDataFileSystem::OnFilePathUpdated(const FileOperationCallback& callback,
3018 GDataFileError error, 3027 GDataFileError error,
3019 const FilePath& file_path) { 3028 const FilePath& file_path) {
3020 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 3029 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
3021 if (!callback.is_null()) 3030 if (!callback.is_null())
3022 callback.Run(error); 3031 callback.Run(error);
3023 } 3032 }
3024 3033
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
3381 LOG(ERROR) << "Entry for the existing file not found: " << resource_id; 3390 LOG(ERROR) << "Entry for the existing file not found: " << resource_id;
3382 } 3391 }
3383 } 3392 }
3384 3393
3385 void GDataFileSystem::RunAndNotifyInitialLoadFinished( 3394 void GDataFileSystem::RunAndNotifyInitialLoadFinished(
3386 const FindEntryCallback& callback, 3395 const FindEntryCallback& callback,
3387 GDataFileError error, 3396 GDataFileError error,
3388 GDataEntry* entry) { 3397 GDataEntry* entry) {
3389 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 3398 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
3390 3399
3391 DVLOG(1) << "Initial load finished";
3392 if (!callback.is_null()) 3400 if (!callback.is_null())
3393 callback.Run(error, entry); 3401 callback.Run(error, entry);
3394 3402
3403 DVLOG(1) << "RunAndNotifyInitialLoadFinished";
3404
3395 // Notify the observers that root directory has been initialized. 3405 // Notify the observers that root directory has been initialized.
3396 FOR_EACH_OBSERVER(GDataFileSystemInterface::Observer, observers_, 3406 FOR_EACH_OBSERVER(GDataFileSystemInterface::Observer, observers_,
3397 OnInitialLoadFinished()); 3407 OnInitialLoadFinished());
3398 } 3408 }
3399 3409
3400 GDataFileError GDataFileSystem::AddNewDirectory( 3410 GDataFileError GDataFileSystem::AddNewDirectory(
3401 const FilePath& directory_path, base::Value* entry_value) { 3411 const FilePath& directory_path, base::Value* entry_value) {
3402 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 3412 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
3403 3413
3404 if (!entry_value) 3414 if (!entry_value)
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
4047 } 4057 }
4048 4058
4049 PlatformFileInfoProto entry_file_info; 4059 PlatformFileInfoProto entry_file_info;
4050 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); 4060 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info);
4051 *entry_proto->mutable_file_info() = entry_file_info; 4061 *entry_proto->mutable_file_info() = entry_file_info;
4052 if (!callback.is_null()) 4062 if (!callback.is_null())
4053 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); 4063 callback.Run(GDATA_FILE_OK, entry_proto.Pass());
4054 } 4064 }
4055 4065
4056 } // namespace gdata 4066 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_file_system.h ('k') | chrome/browser/chromeos/gdata/gdata_files.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698