OLD | NEW |
---|---|
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 if (remote_file_service_) |
53 remote_file_service_->RegisterOriginForTrackingChanges(app_url.GetOrigin()); | |
kinuko
2012/10/24 05:17:21
I think this line should be added when you add imp
tzik
2012/10/24 05:32:52
Done.
| |
50 } | 54 } |
51 | 55 |
52 SyncFileSystemService::SyncFileSystemService(Profile* profile) | 56 SyncFileSystemService::SyncFileSystemService(Profile* profile) |
53 : profile_(profile) {} | 57 : profile_(profile) {} |
54 | 58 |
55 void SyncFileSystemService::Initialize( | 59 void SyncFileSystemService::Initialize( |
56 scoped_ptr<LocalFileSyncService> local_file_service) { | 60 scoped_ptr<LocalFileSyncService> local_file_service, |
61 scoped_ptr<RemoteFileSyncService> remote_file_service) { | |
57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
58 DCHECK(local_file_service.get()); | 63 DCHECK(local_file_service.get()); |
59 DCHECK(profile_); | 64 DCHECK(profile_); |
60 | 65 |
61 local_file_service_ = local_file_service.Pass(); | 66 local_file_service_ = local_file_service.Pass(); |
67 remote_file_service_ = remote_file_service.Pass(); | |
68 | |
69 // TODO(tzik): Uncomment this line after RemoteChangeObserver lands. | |
70 // remote_file_service_->AddObserver(this); | |
62 } | 71 } |
63 | 72 |
64 // SyncFileSystemServiceFactory ----------------------------------------------- | 73 // SyncFileSystemServiceFactory ----------------------------------------------- |
65 | 74 |
66 // static | 75 // static |
67 SyncFileSystemService* SyncFileSystemServiceFactory::GetForProfile( | 76 SyncFileSystemService* SyncFileSystemServiceFactory::GetForProfile( |
68 Profile* profile) { | 77 Profile* profile) { |
69 return static_cast<SyncFileSystemService*>( | 78 return static_cast<SyncFileSystemService*>( |
70 GetInstance()->GetServiceForProfile(profile, true)); | 79 GetInstance()->GetServiceForProfile(profile, true)); |
71 } | 80 } |
(...skipping 12 matching lines...) Expand all Loading... | |
84 | 93 |
85 ProfileKeyedService* SyncFileSystemServiceFactory::BuildServiceInstanceFor( | 94 ProfileKeyedService* SyncFileSystemServiceFactory::BuildServiceInstanceFor( |
86 Profile* profile) const { | 95 Profile* profile) const { |
87 SyncFileSystemService* service = new SyncFileSystemService(profile); | 96 SyncFileSystemService* service = new SyncFileSystemService(profile); |
88 | 97 |
89 // TODO(kinuko): Set up mock services if it is called for testing. | 98 // TODO(kinuko): Set up mock services if it is called for testing. |
90 | 99 |
91 scoped_ptr<LocalFileSyncService> local_file_service( | 100 scoped_ptr<LocalFileSyncService> local_file_service( |
92 new LocalFileSyncService); | 101 new LocalFileSyncService); |
93 | 102 |
94 service->Initialize(local_file_service.Pass()); | 103 scoped_ptr<RemoteFileSyncService> remote_file_service; |
104 // TODO(tzik): Instantiate DriveFileSyncService. | |
105 | |
106 service->Initialize(local_file_service.Pass(), | |
107 remote_file_service.Pass()); | |
95 return service; | 108 return service; |
96 } | 109 } |
97 | 110 |
98 } // namespace chrome | 111 } // namespace sync_file_system |
OLD | NEW |