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

Side by Side Diff: chrome/browser/sync_file_system/local_file_sync_service.cc

Issue 16109008: Cleanup: Deprecate DriveFileSyncService::kServiceName (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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/sync_file_system/local_file_sync_service.h" 5 #include "chrome/browser/sync_file_system/local_file_sync_service.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/extensions/extension_system.h" 9 #include "chrome/browser/extensions/extension_system.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } 108 }
109 109
110 void LocalFileSyncService::Shutdown() { 110 void LocalFileSyncService::Shutdown() {
111 sync_context_->RemoveOriginChangeObserver(this); 111 sync_context_->RemoveOriginChangeObserver(this);
112 sync_context_->ShutdownOnUIThread(); 112 sync_context_->ShutdownOnUIThread();
113 profile_ = NULL; 113 profile_ = NULL;
114 } 114 }
115 115
116 void LocalFileSyncService::MaybeInitializeFileSystemContext( 116 void LocalFileSyncService::MaybeInitializeFileSystemContext(
117 const GURL& app_origin, 117 const GURL& app_origin,
118 const std::string& service_name,
119 fileapi::FileSystemContext* file_system_context, 118 fileapi::FileSystemContext* file_system_context,
120 const SyncStatusCallback& callback) { 119 const SyncStatusCallback& callback) {
121 sync_context_->MaybeInitializeFileSystemContext( 120 sync_context_->MaybeInitializeFileSystemContext(
122 app_origin, service_name, file_system_context, 121 app_origin, file_system_context,
123 base::Bind(&LocalFileSyncService::DidInitializeFileSystemContext, 122 base::Bind(&LocalFileSyncService::DidInitializeFileSystemContext,
124 AsWeakPtr(), app_origin, 123 AsWeakPtr(), app_origin,
125 make_scoped_refptr(file_system_context), callback)); 124 make_scoped_refptr(file_system_context), callback));
126 } 125 }
127 126
128 void LocalFileSyncService::AddChangeObserver(Observer* observer) { 127 void LocalFileSyncService::AddChangeObserver(Observer* observer) {
129 change_observers_.AddObserver(observer); 128 change_observers_.AddObserver(observer);
130 } 129 }
131 130
132 void LocalFileSyncService::RegisterURLForWaitingSync( 131 void LocalFileSyncService::RegisterURLForWaitingSync(
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 181
183 void LocalFileSyncService::GetLocalFileMetadata( 182 void LocalFileSyncService::GetLocalFileMetadata(
184 const FileSystemURL& url, const SyncFileMetadataCallback& callback) { 183 const FileSystemURL& url, const SyncFileMetadataCallback& callback) {
185 DCHECK(ContainsKey(origin_to_contexts_, url.origin())); 184 DCHECK(ContainsKey(origin_to_contexts_, url.origin()));
186 sync_context_->GetFileMetadata(origin_to_contexts_[url.origin()], 185 sync_context_->GetFileMetadata(origin_to_contexts_[url.origin()],
187 url, callback); 186 url, callback);
188 } 187 }
189 188
190 void LocalFileSyncService::PrepareForProcessRemoteChange( 189 void LocalFileSyncService::PrepareForProcessRemoteChange(
191 const FileSystemURL& url, 190 const FileSystemURL& url,
192 const std::string& service_name,
193 const PrepareChangeCallback& callback) { 191 const PrepareChangeCallback& callback) {
194 if (!ContainsKey(origin_to_contexts_, url.origin())) { 192 if (!ContainsKey(origin_to_contexts_, url.origin())) {
195 // This could happen if a remote sync is triggered for the app that hasn't 193 // This could happen if a remote sync is triggered for the app that hasn't
196 // been initialized in this service. 194 // been initialized in this service.
197 DCHECK(profile_); 195 DCHECK(profile_);
198 // The given url.origin() must be for valid installed app. 196 // The given url.origin() must be for valid installed app.
199 ExtensionService* extension_service = 197 ExtensionService* extension_service =
200 extensions::ExtensionSystem::Get(profile_)->extension_service(); 198 extensions::ExtensionSystem::Get(profile_)->extension_service();
201 const extensions::Extension* extension = extension_service->GetInstalledApp( 199 const extensions::Extension* extension = extension_service->GetInstalledApp(
202 url.origin()); 200 url.origin());
(...skipping 10 matching lines...) Expand all
213 SyncFileMetadata(), FileChangeList()); 211 SyncFileMetadata(), FileChangeList());
214 return; 212 return;
215 } 213 }
216 GURL site_url = extension_service->GetSiteForExtensionId(extension->id()); 214 GURL site_url = extension_service->GetSiteForExtensionId(extension->id());
217 DCHECK(!site_url.is_empty()); 215 DCHECK(!site_url.is_empty());
218 scoped_refptr<fileapi::FileSystemContext> file_system_context = 216 scoped_refptr<fileapi::FileSystemContext> file_system_context =
219 content::BrowserContext::GetStoragePartitionForSite( 217 content::BrowserContext::GetStoragePartitionForSite(
220 profile_, site_url)->GetFileSystemContext(); 218 profile_, site_url)->GetFileSystemContext();
221 MaybeInitializeFileSystemContext( 219 MaybeInitializeFileSystemContext(
222 url.origin(), 220 url.origin(),
223 service_name,
224 file_system_context.get(), 221 file_system_context.get(),
225 base::Bind(&LocalFileSyncService::DidInitializeForRemoteSync, 222 base::Bind(&LocalFileSyncService::DidInitializeForRemoteSync,
226 AsWeakPtr(), 223 AsWeakPtr(),
227 url, 224 url,
228 service_name,
229 file_system_context, 225 file_system_context,
230 callback)); 226 callback));
231 return; 227 return;
232 } 228 }
233 229
234 DCHECK(ContainsKey(origin_to_contexts_, url.origin())); 230 DCHECK(ContainsKey(origin_to_contexts_, url.origin()));
235 sync_context_->PrepareForSync( 231 sync_context_->PrepareForSync(
236 origin_to_contexts_[url.origin()], url, 232 origin_to_contexts_[url.origin()], url,
237 base::Bind(&PrepareForProcessRemoteChangeCallbackAdapter, callback)); 233 base::Bind(&PrepareForProcessRemoteChangeCallbackAdapter, callback));
238 } 234 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 app_origin, file_system_context->change_tracker()->num_changes()); 316 app_origin, file_system_context->change_tracker()->num_changes());
321 int64 num_changes = origin_change_map_.GetTotalChangeCount(); 317 int64 num_changes = origin_change_map_.GetTotalChangeCount();
322 FOR_EACH_OBSERVER(Observer, change_observers_, 318 FOR_EACH_OBSERVER(Observer, change_observers_,
323 OnLocalChangeAvailable(num_changes)); 319 OnLocalChangeAvailable(num_changes));
324 } 320 }
325 callback.Run(status); 321 callback.Run(status);
326 } 322 }
327 323
328 void LocalFileSyncService::DidInitializeForRemoteSync( 324 void LocalFileSyncService::DidInitializeForRemoteSync(
329 const FileSystemURL& url, 325 const FileSystemURL& url,
330 const std::string& service_name,
331 fileapi::FileSystemContext* file_system_context, 326 fileapi::FileSystemContext* file_system_context,
332 const PrepareChangeCallback& callback, 327 const PrepareChangeCallback& callback,
333 SyncStatusCode status) { 328 SyncStatusCode status) {
334 if (status != SYNC_STATUS_OK) { 329 if (status != SYNC_STATUS_OK) {
335 DVLOG(1) << "FileSystemContext initialization failed for remote sync:" 330 DVLOG(1) << "FileSystemContext initialization failed for remote sync:"
336 << url.DebugString() << " status=" << status 331 << url.DebugString() << " status=" << status
337 << " (" << SyncStatusCodeToString(status) << ")"; 332 << " (" << SyncStatusCodeToString(status) << ")";
338 callback.Run(status, SyncFileMetadata(), FileChangeList()); 333 callback.Run(status, SyncFileMetadata(), FileChangeList());
339 return; 334 return;
340 } 335 }
341 origin_to_contexts_[url.origin()] = file_system_context; 336 origin_to_contexts_[url.origin()] = file_system_context;
342 PrepareForProcessRemoteChange(url, service_name, callback); 337 PrepareForProcessRemoteChange(url, callback);
343 } 338 }
344 339
345 void LocalFileSyncService::RunLocalSyncCallback( 340 void LocalFileSyncService::RunLocalSyncCallback(
346 SyncStatusCode status, 341 SyncStatusCode status,
347 const FileSystemURL& url) { 342 const FileSystemURL& url) {
348 DCHECK(!local_sync_callback_.is_null()); 343 DCHECK(!local_sync_callback_.is_null());
349 SyncFileCallback callback = local_sync_callback_; 344 SyncFileCallback callback = local_sync_callback_;
350 local_sync_callback_.Reset(); 345 local_sync_callback_.Reset();
351 callback.Run(status, url); 346 callback.Run(status, url);
352 } 347 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 changes.front(), 417 changes.front(),
423 sync_file_info.local_file_path, 418 sync_file_info.local_file_path,
424 sync_file_info.metadata, 419 sync_file_info.metadata,
425 url, 420 url,
426 base::Bind(&LocalFileSyncService::ProcessNextChangeForURL, 421 base::Bind(&LocalFileSyncService::ProcessNextChangeForURL,
427 AsWeakPtr(), sync_file_info, 422 AsWeakPtr(), sync_file_info,
428 changes.front(), changes.PopAndGetNewList())); 423 changes.front(), changes.PopAndGetNewList()));
429 } 424 }
430 425
431 } // namespace sync_file_system 426 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698