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

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: 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_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 13 matching lines...) Expand all
71 {-1, 1}, // Any size, dump if older than 1 minute. 75 {-1, 1}, // Any size, dump if older than 1 minute.
72 #else 76 #else
73 {0.5, 0}, // Less than 0.5MB, dump immediately. 77 {0.5, 0}, // Less than 0.5MB, dump immediately.
74 {1.0, 15}, // Less than 1.0MB, dump after 15 minutes. 78 {1.0, 15}, // Less than 1.0MB, dump after 15 minutes.
75 {2.0, 30}, 79 {2.0, 30},
76 {4.0, 60}, 80 {4.0, 60},
77 {-1, 120}, // Any size, dump if older than 120 minutes. 81 {-1, 120}, // Any size, dump if older than 120 minutes.
78 #endif 82 #endif
79 }; 83 };
80 84
81 // Defines set of parameters sent to callback OnProtoLoaded().
82 struct LoadRootFeedParams {
83 LoadRootFeedParams(
84 FilePath search_file_path,
85 bool should_load_from_server,
86 const FindEntryCallback& callback)
87 : search_file_path(search_file_path),
88 should_load_from_server(should_load_from_server),
89 load_error(GDATA_FILE_OK),
90 callback(callback) {
91 }
92 ~LoadRootFeedParams() {
93 }
94
95 FilePath search_file_path;
96 bool should_load_from_server;
97 std::string proto;
98 GDataFileError load_error;
99 base::Time last_modified;
100 const FindEntryCallback callback;
101 };
102
103 // Returns true if file system is due to be serialized on disk based on it 85 // Returns true if file system is due to be serialized on disk based on it
104 // |serialized_size| and |last_serialized| timestamp. 86 // |serialized_size| and |last_serialized| timestamp.
105 bool ShouldSerializeFileSystemNow(size_t serialized_size, 87 bool ShouldSerializeFileSystemNow(size_t serialized_size,
106 const base::Time& last_serialized) { 88 const base::Time& last_serialized) {
107 const double size_in_mb = serialized_size / 1048576.0; 89 const double size_in_mb = serialized_size / 1048576.0;
108 const int last_proto_dump_in_min = 90 const int last_proto_dump_in_min =
109 (base::Time::Now() - last_serialized).InMinutes(); 91 (base::Time::Now() - last_serialized).InMinutes();
110 for (size_t i = 0; i < arraysize(kSerializeTimetable); i++) { 92 for (size_t i = 0; i < arraysize(kSerializeTimetable); i++) {
111 if ((size_in_mb < kSerializeTimetable[i].size || 93 if ((size_in_mb < kSerializeTimetable[i].size ||
112 kSerializeTimetable[i].size == -1) && 94 kSerializeTimetable[i].size == -1) &&
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 LOG(WARNING) << "GData metadata file can't be stored at " 248 LOG(WARNING) << "GData metadata file can't be stored at "
267 << file_path.value(); 249 << file_path.value();
268 if (!file_util::Delete(file_path, true)) { 250 if (!file_util::Delete(file_path, true)) {
269 LOG(WARNING) << "GData metadata file can't be deleted at " 251 LOG(WARNING) << "GData metadata file can't be deleted at "
270 << file_path.value(); 252 << file_path.value();
271 return; 253 return;
272 } 254 }
273 } 255 }
274 } 256 }
275 257
258 bool UseLevelDB() {
259 return CommandLine::ForCurrentProcess()->HasSwitch(
260 switches::kUseLevelDBForGData);
261 }
262
276 // Gets the file size of |local_file|. 263 // Gets the file size of |local_file|.
277 void GetLocalFileSizeOnBlockingPool(const FilePath& local_file, 264 void GetLocalFileSizeOnBlockingPool(const FilePath& local_file,
278 GDataFileError* error, 265 GDataFileError* error,
279 int64* file_size) { 266 int64* file_size) {
280 DCHECK(error); 267 DCHECK(error);
281 DCHECK(file_size); 268 DCHECK(file_size);
282 269
283 *file_size = 0; 270 *file_size = 0;
284 *error = file_util::GetFileSize(local_file, file_size) ? 271 *error = file_util::GetFileSize(local_file, file_size) ?
285 GDATA_FILE_OK : 272 GDATA_FILE_OK :
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 directory_service_->FindEntryByPathAndRunSync(search_file_path, callback); 974 directory_service_->FindEntryByPathAndRunSync(search_file_path, callback);
988 } 975 }
989 976
990 void GDataWapiFeedLoader::ReloadFromServerIfNeeded( 977 void GDataWapiFeedLoader::ReloadFromServerIfNeeded(
991 ContentOrigin initial_origin, 978 ContentOrigin initial_origin,
992 int local_changestamp, 979 int local_changestamp,
993 const FilePath& search_file_path, 980 const FilePath& search_file_path,
994 const FindEntryCallback& callback) { 981 const FindEntryCallback& callback) {
995 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 982 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
996 983
984 DVLOG(1) << "ReloadFeedFromServerIfNeeded local_changestamp="
985 << local_changestamp << ", initial_origin=" << initial_origin;
986
997 // First fetch the latest changestamp to see if there were any new changes 987 // First fetch the latest changestamp to see if there were any new changes
998 // there at all. 988 // there at all.
999 documents_service_->GetAccountMetadata( 989 documents_service_->GetAccountMetadata(
1000 base::Bind(&GDataWapiFeedLoader::OnGetAccountMetadata, 990 base::Bind(&GDataWapiFeedLoader::OnGetAccountMetadata,
1001 weak_ptr_factory_.GetWeakPtr(), 991 weak_ptr_factory_.GetWeakPtr(),
1002 initial_origin, 992 initial_origin,
1003 local_changestamp, 993 local_changestamp,
1004 search_file_path, 994 search_file_path,
1005 callback)); 995 callback));
1006 } 996 }
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 params->root_feed_changestamp); 1140 params->root_feed_changestamp);
1151 1141
1152 if (error != GDATA_FILE_OK) { 1142 if (error != GDATA_FILE_OK) {
1153 if (!params->callback.is_null()) 1143 if (!params->callback.is_null())
1154 params->callback.Run(error, NULL); 1144 params->callback.Run(error, NULL);
1155 1145
1156 return; 1146 return;
1157 } 1147 }
1158 1148
1159 // Save file system metadata to disk. 1149 // Save file system metadata to disk.
1160 SaveFileSystemAsProto(); 1150 SaveFileSystem();
1161 1151
1162 // If we had someone to report this too, then this retrieval was done in a 1152 // If we had someone to report this too, then this retrieval was done in a
1163 // context of search... so continue search. 1153 // context of search... so continue search.
1164 if (!params->callback.is_null()) { 1154 if (!params->callback.is_null()) {
1165 directory_service_->FindEntryByPathAndRunSync(params->search_file_path, 1155 directory_service_->FindEntryByPathAndRunSync(params->search_file_path,
1166 params->callback); 1156 params->callback);
1167 } 1157 }
1168 1158
1169 FOR_EACH_OBSERVER(Observer, observers_, OnFeedFromServerLoaded()); 1159 FOR_EACH_OBSERVER(Observer, observers_, OnFeedFromServerLoaded());
1170 } 1160 }
(...skipping 1803 matching lines...) Expand 10 before | Expand all | Expand 10 after
2974 } 2964 }
2975 } 2965 }
2976 } 2966 }
2977 2967
2978 void GDataWapiFeedLoader::LoadFromCache( 2968 void GDataWapiFeedLoader::LoadFromCache(
2979 bool should_load_from_server, 2969 bool should_load_from_server,
2980 const FilePath& search_file_path, 2970 const FilePath& search_file_path,
2981 const FindEntryCallback& callback) { 2971 const FindEntryCallback& callback) {
2982 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2972 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2983 2973
2984 const FilePath path =
2985 cache_->GetCacheDirectoryPath(GDataCache::CACHE_TYPE_META).Append(
2986 kFilesystemProtoFile);
2987 LoadRootFeedParams* params = new LoadRootFeedParams(search_file_path, 2974 LoadRootFeedParams* params = new LoadRootFeedParams(search_file_path,
2988 should_load_from_server, 2975 should_load_from_server,
2989 callback); 2976 callback);
2990 BrowserThread::GetBlockingPool()->PostTaskAndReply(FROM_HERE, 2977 FilePath path = cache_->GetCacheDirectoryPath(GDataCache::CACHE_TYPE_META);
2991 base::Bind(&LoadProtoOnBlockingPool, path, params), 2978 if (UseLevelDB()) {
2992 base::Bind(&GDataWapiFeedLoader::OnProtoLoaded, 2979 path = path.Append(kResourceMetadataDBFile);
2993 weak_ptr_factory_.GetWeakPtr(), 2980 directory_service_->InitFromDB(path, blocking_task_runner_,
2994 base::Owned(params))); 2981 base::Bind(
2982 &GDataWapiFeedLoader::ContinueWithInitializedDirectoryService,
2983 weak_ptr_factory_.GetWeakPtr(),
2984 base::Owned(params)));
2985 } else {
2986 path = path.Append(kFilesystemProtoFile);
2987 BrowserThread::GetBlockingPool()->PostTaskAndReply(FROM_HERE,
2988 base::Bind(&LoadProtoOnBlockingPool, path, params),
2989 base::Bind(&GDataWapiFeedLoader::OnProtoLoaded,
2990 weak_ptr_factory_.GetWeakPtr(),
2991 base::Owned(params)));
2992 }
2995 } 2993 }
2996 2994
2997 void GDataFileSystem::OnDirectoryChanged(const FilePath& directory_path) { 2995 void GDataFileSystem::OnDirectoryChanged(const FilePath& directory_path) {
2998 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2996 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2999 2997
3000 FOR_EACH_OBSERVER(GDataFileSystemInterface::Observer, observers_, 2998 FOR_EACH_OBSERVER(GDataFileSystemInterface::Observer, observers_,
3001 OnDirectoryChanged(directory_path)); 2999 OnDirectoryChanged(directory_path));
3002 } 3000 }
3003 3001
3004 void GDataFileSystem::OnDocumentFeedFetched(int num_accumulated_entries) { 3002 void GDataFileSystem::OnDocumentFeedFetched(int num_accumulated_entries) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
3036 root_feed_changestamp); 3034 root_feed_changestamp);
3037 } 3035 }
3038 3036
3039 void GDataWapiFeedLoader::OnProtoLoaded(LoadRootFeedParams* params) { 3037 void GDataWapiFeedLoader::OnProtoLoaded(LoadRootFeedParams* params) {
3040 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 3038 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
3041 3039
3042 // If we have already received updates from the server, bail out. 3040 // If we have already received updates from the server, bail out.
3043 if (directory_service_->origin() == FROM_SERVER) 3041 if (directory_service_->origin() == FROM_SERVER)
3044 return; 3042 return;
3045 3043
3046 int local_changestamp = 0;
3047 // Update directory structure only if everything is OK and we haven't yet 3044 // Update directory structure only if everything is OK and we haven't yet
3048 // received the feed from the server yet. 3045 // received the feed from the server yet.
3049 if (params->load_error == GDATA_FILE_OK) { 3046 if (params->load_error == GDATA_FILE_OK) {
3050 DVLOG(1) << "ParseFromString"; 3047 DVLOG(1) << "ParseFromString";
3051 if (directory_service_->ParseFromString(params->proto)) { 3048 if (directory_service_->ParseFromString(params->proto)) {
3052 directory_service_->set_last_serialized(params->last_modified); 3049 directory_service_->set_last_serialized(params->last_modified);
3053 directory_service_->set_serialized_size(params->proto.size()); 3050 directory_service_->set_serialized_size(params->proto.size());
3054 local_changestamp = directory_service_->largest_changestamp();
3055 } else { 3051 } else {
3056 params->load_error = GDATA_FILE_ERROR_FAILED; 3052 params->load_error = GDATA_FILE_ERROR_FAILED;
3057 LOG(WARNING) << "Parse of cached proto file failed"; 3053 LOG(WARNING) << "Parse of cached proto file failed";
3058 } 3054 }
3059 } 3055 }
3060 3056
3057 ContinueWithInitializedDirectoryService(params, params->load_error);
3058 }
3059
3060 void GDataWapiFeedLoader::ContinueWithInitializedDirectoryService(
3061 LoadRootFeedParams* params,
3062 GDataFileError error) {
3063 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
3064
3065 DVLOG(1) << "Time elapsed to load directory service from disk="
3066 << (base::Time::Now() - params->load_start_time).InMilliseconds()
3067 << " milliseconds";
3068
3061 FindEntryCallback callback = params->callback; 3069 FindEntryCallback callback = params->callback;
3062 // If we got feed content from cache, try search over it. 3070 // If we got feed content from cache, try search over it.
3063 if (params->load_error == GDATA_FILE_OK && !callback.is_null()) { 3071 if (error == GDATA_FILE_OK && !callback.is_null()) {
3064 // Continue file content search operation if the delegate hasn't terminated 3072 // Continue file content search operation if the delegate hasn't terminated
3065 // this search branch already. 3073 // this search branch already.
3066 directory_service_->FindEntryByPathAndRunSync(params->search_file_path, 3074 directory_service_->FindEntryByPathAndRunSync(params->search_file_path,
3067 callback); 3075 callback);
3068 callback.Reset(); 3076 callback.Reset();
3069 } 3077 }
3070 3078
3071 if (!params->should_load_from_server) 3079 if (!params->should_load_from_server)
3072 return; 3080 return;
3073 3081
3074 // Decide the |initial_origin| to pass to ReloadFromServerIfNeeded(). 3082 // Decide the |initial_origin| to pass to ReloadFromServerIfNeeded().
3075 // This is used to restore directory content origin to its initial value when 3083 // This is used to restore directory content origin to its initial value when
3076 // we fail to retrieve the feed from server. 3084 // we fail to retrieve the feed from server.
3077 // By default, if directory content is not yet initialized, restore content 3085 // By default, if directory content is not yet initialized, restore content
3078 // origin to UNINITIALIZED in case of failure. 3086 // origin to UNINITIALIZED in case of failure.
3079 ContentOrigin initial_origin = UNINITIALIZED; 3087 ContentOrigin initial_origin = UNINITIALIZED;
3080 if (directory_service_->origin() != INITIALIZING) { 3088 if (directory_service_->origin() != INITIALIZING) {
3081 // If directory content is already initialized, restore content origin 3089 // If directory content is already initialized, restore content origin
3082 // to FROM_CACHE in case of failure. 3090 // to FROM_CACHE in case of failure.
3083 initial_origin = FROM_CACHE; 3091 initial_origin = FROM_CACHE;
3084 directory_service_->set_origin(REFRESHING); 3092 directory_service_->set_origin(REFRESHING);
3085 } 3093 }
3086 3094
3087 // Kick of the retrieval of the feed from server. If we have previously 3095 // Kick of the retrieval of the feed from server. If we have previously
3088 // |reported| to the original callback, then we just need to refresh the 3096 // |reported| to the original callback, then we just need to refresh the
3089 // content without continuing search upon operation completion. 3097 // content without continuing search upon operation completion.
3090 ReloadFromServerIfNeeded(initial_origin, 3098 ReloadFromServerIfNeeded(initial_origin,
3091 local_changestamp, 3099 directory_service_->largest_changestamp(),
3092 params->search_file_path, 3100 params->search_file_path,
3093 callback); 3101 callback);
3094 } 3102 }
3095 3103
3096 void GDataWapiFeedLoader::SaveFileSystemAsProto() { 3104 void GDataWapiFeedLoader::SaveFileSystem() {
3097 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 3105 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
3098 3106
3099 DVLOG(1) << "SaveFileSystemAsProto";
3100
3101 if (!ShouldSerializeFileSystemNow(directory_service_->serialized_size(), 3107 if (!ShouldSerializeFileSystemNow(directory_service_->serialized_size(),
3102 directory_service_->last_serialized())) { 3108 directory_service_->last_serialized())) {
3103 return; 3109 return;
3104 } 3110 }
3105 3111
3106 const FilePath path = 3112 if (UseLevelDB()) {
3107 cache_->GetCacheDirectoryPath(GDataCache::CACHE_TYPE_META).Append( 3113 directory_service_->SaveToDB();
3108 kFilesystemProtoFile); 3114 } else {
3109 scoped_ptr<std::string> serialized_proto(new std::string()); 3115 const FilePath path =
3110 directory_service_->SerializeToString(serialized_proto.get()); 3116 cache_->GetCacheDirectoryPath(GDataCache::CACHE_TYPE_META).Append(
3111 directory_service_->set_last_serialized(base::Time::Now()); 3117 kFilesystemProtoFile);
3112 directory_service_->set_serialized_size(serialized_proto->size()); 3118 scoped_ptr<std::string> serialized_proto(new std::string());
3113 PostBlockingPoolSequencedTask( 3119 directory_service_->SerializeToString(serialized_proto.get());
3114 FROM_HERE, 3120 directory_service_->set_last_serialized(base::Time::Now());
3115 blocking_task_runner_, 3121 directory_service_->set_serialized_size(serialized_proto->size());
3116 base::Bind(&SaveProtoOnBlockingPool, path, 3122 PostBlockingPoolSequencedTask(
3117 base::Passed(serialized_proto.Pass()))); 3123 FROM_HERE,
3124 blocking_task_runner_,
3125 base::Bind(&SaveProtoOnBlockingPool, path,
3126 base::Passed(serialized_proto.Pass())));
3127 }
3118 } 3128 }
3119 3129
3120 void GDataFileSystem::OnFilePathUpdated(const FileOperationCallback& callback, 3130 void GDataFileSystem::OnFilePathUpdated(const FileOperationCallback& callback,
3121 GDataFileError error, 3131 GDataFileError error,
3122 const FilePath& file_path) { 3132 const FilePath& file_path) {
3123 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 3133 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
3124 if (!callback.is_null()) 3134 if (!callback.is_null())
3125 callback.Run(error); 3135 callback.Run(error);
3126 } 3136 }
3127 3137
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
3502 FOR_EACH_OBSERVER(GDataFileSystemInterface::Observer, observers_, 3512 FOR_EACH_OBSERVER(GDataFileSystemInterface::Observer, observers_,
3503 OnFileSystemBeingUnmounted()); 3513 OnFileSystemBeingUnmounted());
3504 } 3514 }
3505 3515
3506 void GDataFileSystem::RunAndNotifyInitialLoadFinished( 3516 void GDataFileSystem::RunAndNotifyInitialLoadFinished(
3507 const FindEntryCallback& callback, 3517 const FindEntryCallback& callback,
3508 GDataFileError error, 3518 GDataFileError error,
3509 GDataEntry* entry) { 3519 GDataEntry* entry) {
3510 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 3520 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
3511 3521
3512 DVLOG(1) << "Initial load finished";
3513 if (!callback.is_null()) 3522 if (!callback.is_null())
3514 callback.Run(error, entry); 3523 callback.Run(error, entry);
3515 3524
3525 DVLOG(1) << "RunAndNotifyInitialLoadFinished";
3526
3516 // Notify the observers that root directory has been initialized. 3527 // Notify the observers that root directory has been initialized.
3517 FOR_EACH_OBSERVER(GDataFileSystemInterface::Observer, observers_, 3528 FOR_EACH_OBSERVER(GDataFileSystemInterface::Observer, observers_,
3518 OnInitialLoadFinished()); 3529 OnInitialLoadFinished());
3519 } 3530 }
3520 3531
3521 GDataFileError GDataFileSystem::AddNewDirectory( 3532 GDataFileError GDataFileSystem::AddNewDirectory(
3522 const FilePath& directory_path, base::Value* entry_value) { 3533 const FilePath& directory_path, base::Value* entry_value) {
3523 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 3534 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
3524 3535
3525 if (!entry_value) 3536 if (!entry_value)
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
4168 } 4179 }
4169 4180
4170 PlatformFileInfoProto entry_file_info; 4181 PlatformFileInfoProto entry_file_info;
4171 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); 4182 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info);
4172 *entry_proto->mutable_file_info() = entry_file_info; 4183 *entry_proto->mutable_file_info() = entry_file_info;
4173 if (!callback.is_null()) 4184 if (!callback.is_null())
4174 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); 4185 callback.Run(GDATA_FILE_OK, entry_proto.Pass());
4175 } 4186 }
4176 4187
4177 } // namespace gdata 4188 } // 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