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

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

Issue 11187021: Add RemoteFileSyncService interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 8 years, 2 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/sync_file_system_service.h" 5 #include "chrome/browser/sync_file_system/sync_file_system_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/profiles/profile_dependency_manager.h" 11 #include "chrome/browser/profiles/profile_dependency_manager.h"
12 #include "chrome/browser/sync_file_system/local_file_sync_service.h" 12 #include "chrome/browser/sync_file_system/local_file_sync_service.h"
13 #include "chrome/browser/sync_file_system/remote_file_sync_service.h"
13 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
14 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
15 #include "webkit/fileapi/file_system_context.h" 16 #include "webkit/fileapi/file_system_context.h"
16 #include "webkit/fileapi/syncable/sync_status_code.h" 17 #include "webkit/fileapi/syncable/sync_status_code.h"
17 18
18 using content::BrowserThread; 19 using content::BrowserThread;
19 20
20 namespace sync_file_system { 21 namespace sync_file_system {
21 22
22 void SyncFileSystemService::Shutdown() { 23 void SyncFileSystemService::Shutdown() {
23 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 24 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
24 25
25 local_file_service_->Shutdown(); 26 local_file_service_->Shutdown();
26 local_file_service_.reset(); 27 local_file_service_.reset();
27 28
29 // TODO(tzik): Uncomment this line after RemoteChangeObserver lands.
30 // remote_file_service_->RemoveObserver(this);
kinuko 2012/10/23 08:12:14 Not sure if this line is really necessary...
tzik 2012/10/24 03:32:33 Done.
31 remote_file_service_.reset();
32
28 profile_ = NULL; 33 profile_ = NULL;
29 } 34 }
30 35
31 SyncFileSystemService::~SyncFileSystemService() { 36 SyncFileSystemService::~SyncFileSystemService() {
32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 37 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
33 DCHECK(!profile_); 38 DCHECK(!profile_);
34 } 39 }
35 40
36 void SyncFileSystemService::InitializeForApp( 41 void SyncFileSystemService::InitializeForApp(
37 fileapi::FileSystemContext* file_system_context, 42 fileapi::FileSystemContext* file_system_context,
38 const std::string& service_name, 43 const std::string& service_name,
39 const GURL& app_url, 44 const GURL& app_url,
40 const StatusCallback& callback) { 45 const StatusCallback& callback) {
41 DCHECK(local_file_service_.get()); 46 DCHECK(local_file_service_);
42 47
43 // TODO(kinuko,tzik): Instantiate the remote_file_service for the given 48 // TODO(kinuko,tzik): Instantiate the remote_file_service for the given
44 // |service_name| if it hasn't been initialized. 49 // |service_name| if it hasn't been initialized.
45 50
46 local_file_service_->MaybeInitializeFileSystemContext( 51 local_file_service_->MaybeInitializeFileSystemContext(
47 app_url, file_system_context, callback); 52 app_url.GetOrigin(), file_system_context, callback);
48 53
49 // TODO(tzik): Hook up remote service initialization code. 54 if (remote_file_service_)
55 remote_file_service_->RegisterOriginForTrackingChanges(app_url.GetOrigin());
50 } 56 }
51 57
52 SyncFileSystemService::SyncFileSystemService(Profile* profile) 58 SyncFileSystemService::SyncFileSystemService(Profile* profile)
53 : profile_(profile) {} 59 : profile_(profile) {}
54 60
55 void SyncFileSystemService::Initialize( 61 void SyncFileSystemService::Initialize(
56 scoped_ptr<LocalFileSyncService> local_file_service) { 62 scoped_ptr<LocalFileSyncService> local_file_service,
63 scoped_ptr<RemoteFileSyncService> remote_file_service) {
57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
58 DCHECK(local_file_service.get()); 65 DCHECK(local_file_service.get());
59 DCHECK(profile_); 66 DCHECK(profile_);
60 67
61 local_file_service_ = local_file_service.Pass(); 68 local_file_service_ = local_file_service.Pass();
69 remote_file_service_ = remote_file_service.Pass();
70
71 // TODO(tzik): Uncomment this line after RemoteChangeObserver lands.
72 // remote_file_service_->AddObserver(this);
62 } 73 }
63 74
64 // SyncFileSystemServiceFactory ----------------------------------------------- 75 // SyncFileSystemServiceFactory -----------------------------------------------
65 76
66 // static 77 // static
67 SyncFileSystemService* SyncFileSystemServiceFactory::GetForProfile( 78 SyncFileSystemService* SyncFileSystemServiceFactory::GetForProfile(
68 Profile* profile) { 79 Profile* profile) {
69 return static_cast<SyncFileSystemService*>( 80 return static_cast<SyncFileSystemService*>(
70 GetInstance()->GetServiceForProfile(profile, true)); 81 GetInstance()->GetServiceForProfile(profile, true));
71 } 82 }
(...skipping 12 matching lines...) Expand all
84 95
85 ProfileKeyedService* SyncFileSystemServiceFactory::BuildServiceInstanceFor( 96 ProfileKeyedService* SyncFileSystemServiceFactory::BuildServiceInstanceFor(
86 Profile* profile) const { 97 Profile* profile) const {
87 SyncFileSystemService* service = new SyncFileSystemService(profile); 98 SyncFileSystemService* service = new SyncFileSystemService(profile);
88 99
89 // TODO(kinuko): Set up mock services if it is called for testing. 100 // TODO(kinuko): Set up mock services if it is called for testing.
90 101
91 scoped_ptr<LocalFileSyncService> local_file_service( 102 scoped_ptr<LocalFileSyncService> local_file_service(
92 new LocalFileSyncService); 103 new LocalFileSyncService);
93 104
94 service->Initialize(local_file_service.Pass()); 105 scoped_ptr<RemoteFileSyncService> remote_file_service;
106 // TODO(tzik): Instantiate DriveFileSyncService.
107
108 service->Initialize(local_file_service.Pass(),
109 remote_file_service.Pass());
95 return service; 110 return service;
96 } 111 }
97 112
98 } // namespace chrome 113 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698