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

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: rebase again 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
« no previous file with comments | « chrome/browser/sync_file_system/sync_file_system_service.h ('k') | chrome/chrome_browser.gypi » ('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/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 remote_file_service_.reset();
30
28 profile_ = NULL; 31 profile_ = NULL;
29 } 32 }
30 33
31 SyncFileSystemService::~SyncFileSystemService() { 34 SyncFileSystemService::~SyncFileSystemService() {
32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
33 DCHECK(!profile_); 36 DCHECK(!profile_);
34 } 37 }
35 38
36 void SyncFileSystemService::InitializeForApp( 39 void SyncFileSystemService::InitializeForApp(
37 fileapi::FileSystemContext* file_system_context, 40 fileapi::FileSystemContext* file_system_context,
38 const std::string& service_name, 41 const std::string& service_name,
39 const GURL& app_url, 42 const GURL& app_url,
40 const StatusCallback& callback) { 43 const StatusCallback& callback) {
41 DCHECK(local_file_service_.get()); 44 DCHECK(local_file_service_);
42 45
43 // TODO(kinuko,tzik): Instantiate the remote_file_service for the given 46 // TODO(kinuko,tzik): Instantiate the remote_file_service for the given
44 // |service_name| if it hasn't been initialized. 47 // |service_name| if it hasn't been initialized.
45 48
46 local_file_service_->MaybeInitializeFileSystemContext( 49 local_file_service_->MaybeInitializeFileSystemContext(
47 app_url, file_system_context, callback); 50 app_url.GetOrigin(), file_system_context, callback);
48 51
49 // TODO(tzik): Hook up remote service initialization code. 52 // TODO(tzik): Uncomment this line after its implementation lands.
53 // remote_file_service_->RegisterOriginForTrackingChanges(
54 // app_url.GetOrigin());
50 } 55 }
51 56
52 void SyncFileSystemService::OnLocalChangeAvailable(int64 pending_changes) { 57 void SyncFileSystemService::OnLocalChangeAvailable(int64 pending_changes) {
53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
54 DCHECK_GE(pending_changes, 0); 59 DCHECK_GE(pending_changes, 0);
55 pending_local_changes_ = pending_changes; 60 pending_local_changes_ = pending_changes;
56 } 61 }
57 62
58 void SyncFileSystemService::OnRemoteChangeAvailable(int64 pending_changes) { 63 void SyncFileSystemService::OnRemoteChangeAvailable(int64 pending_changes) {
59 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
60 DCHECK_GE(pending_changes, 0); 65 DCHECK_GE(pending_changes, 0);
61 pending_remote_changes_ = pending_changes; 66 pending_remote_changes_ = pending_changes;
62 } 67 }
63 68
64 SyncFileSystemService::SyncFileSystemService(Profile* profile) 69 SyncFileSystemService::SyncFileSystemService(Profile* profile)
65 : profile_(profile), 70 : profile_(profile),
66 pending_local_changes_(0), 71 pending_local_changes_(0),
67 pending_remote_changes_(0) {} 72 pending_remote_changes_(0) {}
68 73
69 void SyncFileSystemService::Initialize( 74 void SyncFileSystemService::Initialize(
70 scoped_ptr<LocalFileSyncService> local_file_service) { 75 scoped_ptr<LocalFileSyncService> local_file_service,
76 scoped_ptr<RemoteFileSyncService> remote_file_service) {
71 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 77 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
72 DCHECK(local_file_service.get()); 78 DCHECK(local_file_service.get());
73 DCHECK(profile_); 79 DCHECK(profile_);
74 80
75 local_file_service_ = local_file_service.Pass(); 81 local_file_service_ = local_file_service.Pass();
82 remote_file_service_ = remote_file_service.Pass();
83
84 // TODO(tzik): Uncomment this line after RemoteChangeObserver lands.
85 // remote_file_service_->AddObserver(this);
76 } 86 }
77 87
78 // SyncFileSystemServiceFactory ----------------------------------------------- 88 // SyncFileSystemServiceFactory -----------------------------------------------
79 89
80 // static 90 // static
81 SyncFileSystemService* SyncFileSystemServiceFactory::GetForProfile( 91 SyncFileSystemService* SyncFileSystemServiceFactory::GetForProfile(
82 Profile* profile) { 92 Profile* profile) {
83 return static_cast<SyncFileSystemService*>( 93 return static_cast<SyncFileSystemService*>(
84 GetInstance()->GetServiceForProfile(profile, true)); 94 GetInstance()->GetServiceForProfile(profile, true));
85 } 95 }
(...skipping 12 matching lines...) Expand all
98 108
99 ProfileKeyedService* SyncFileSystemServiceFactory::BuildServiceInstanceFor( 109 ProfileKeyedService* SyncFileSystemServiceFactory::BuildServiceInstanceFor(
100 Profile* profile) const { 110 Profile* profile) const {
101 SyncFileSystemService* service = new SyncFileSystemService(profile); 111 SyncFileSystemService* service = new SyncFileSystemService(profile);
102 112
103 // TODO(kinuko): Set up mock services if it is called for testing. 113 // TODO(kinuko): Set up mock services if it is called for testing.
104 114
105 scoped_ptr<LocalFileSyncService> local_file_service( 115 scoped_ptr<LocalFileSyncService> local_file_service(
106 new LocalFileSyncService); 116 new LocalFileSyncService);
107 117
108 service->Initialize(local_file_service.Pass()); 118 scoped_ptr<RemoteFileSyncService> remote_file_service;
119 // TODO(tzik): Instantiate DriveFileSyncService.
120
121 service->Initialize(local_file_service.Pass(),
122 remote_file_service.Pass());
109 return service; 123 return service;
110 } 124 }
111 125
112 } // namespace chrome 126 } // namespace sync_file_system
OLDNEW
« no previous file with comments | « chrome/browser/sync_file_system/sync_file_system_service.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698