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

Side by Side Diff: chrome/browser/sync_file_system/local/sync_file_system_backend.cc

Issue 610223002: [SyncFS] Use nullptr instead of NULL (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/sync_file_system_backend.h" 5 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 content::Source<Profile>(profile_)); 45 content::Source<Profile>(profile_));
46 } 46 }
47 47
48 void SyncFileSystemBackend::ProfileHolder::Observe( 48 void SyncFileSystemBackend::ProfileHolder::Observe(
49 int type, 49 int type,
50 const content::NotificationSource& source, 50 const content::NotificationSource& source,
51 const content::NotificationDetails& details) { 51 const content::NotificationDetails& details) {
52 DCHECK(CalledOnUIThread()); 52 DCHECK(CalledOnUIThread());
53 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); 53 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type);
54 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); 54 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr());
55 profile_ = NULL; 55 profile_ = nullptr;
56 registrar_.RemoveAll(); 56 registrar_.RemoveAll();
57 } 57 }
58 58
59 Profile* SyncFileSystemBackend::ProfileHolder::GetProfile() { 59 Profile* SyncFileSystemBackend::ProfileHolder::GetProfile() {
60 DCHECK(CalledOnUIThread()); 60 DCHECK(CalledOnUIThread());
61 return profile_; 61 return profile_;
62 } 62 }
63 63
64 SyncFileSystemBackend::SyncFileSystemBackend(Profile* profile) 64 SyncFileSystemBackend::SyncFileSystemBackend(Profile* profile)
65 : context_(NULL), 65 : context_(nullptr),
66 skip_initialize_syncfs_service_for_testing_(false) { 66 skip_initialize_syncfs_service_for_testing_(false) {
67 DCHECK(CalledOnUIThread()); 67 DCHECK(CalledOnUIThread());
68 if (profile) 68 if (profile)
69 profile_holder_.reset(new ProfileHolder(profile)); 69 profile_holder_.reset(new ProfileHolder(profile));
70 70
71 // Register the service name here to enable to crack an URL on SyncFileSystem 71 // Register the service name here to enable to crack an URL on SyncFileSystem
72 // even if SyncFileSystemService has not started yet. 72 // even if SyncFileSystemService has not started yet.
73 RegisterSyncableFileSystem(); 73 RegisterSyncableFileSystem();
74 } 74 }
75 75
76 SyncFileSystemBackend::~SyncFileSystemBackend() { 76 SyncFileSystemBackend::~SyncFileSystemBackend() {
77 if (change_tracker_) { 77 if (change_tracker_) {
78 GetDelegate()->file_task_runner()->DeleteSoon( 78 GetDelegate()->file_task_runner()->DeleteSoon(
79 FROM_HERE, change_tracker_.release()); 79 FROM_HERE, change_tracker_.release());
80 } 80 }
81 81
82 if (profile_holder_ && !CalledOnUIThread()) { 82 if (profile_holder_ && !CalledOnUIThread()) {
83 BrowserThread::DeleteSoon( 83 BrowserThread::DeleteSoon(
84 BrowserThread::UI, FROM_HERE, profile_holder_.release()); 84 BrowserThread::UI, FROM_HERE, profile_holder_.release());
85 } 85 }
86 } 86 }
87 87
88 // static 88 // static
89 SyncFileSystemBackend* SyncFileSystemBackend::CreateForTesting() { 89 SyncFileSystemBackend* SyncFileSystemBackend::CreateForTesting() {
90 DCHECK(CalledOnUIThread()); 90 DCHECK(CalledOnUIThread());
91 SyncFileSystemBackend* backend = new SyncFileSystemBackend(NULL); 91 SyncFileSystemBackend* backend = new SyncFileSystemBackend(nullptr);
92 backend->skip_initialize_syncfs_service_for_testing_ = true; 92 backend->skip_initialize_syncfs_service_for_testing_ = true;
93 return backend; 93 return backend;
94 } 94 }
95 95
96 bool SyncFileSystemBackend::CanHandleType(storage::FileSystemType type) const { 96 bool SyncFileSystemBackend::CanHandleType(storage::FileSystemType type) const {
97 return type == storage::kFileSystemTypeSyncable || 97 return type == storage::kFileSystemTypeSyncable ||
98 type == storage::kFileSystemTypeSyncableForInternalSync; 98 type == storage::kFileSystemTypeSyncableForInternalSync;
99 } 99 }
100 100
101 void SyncFileSystemBackend::Initialize(storage::FileSystemContext* context) { 101 void SyncFileSystemBackend::Initialize(storage::FileSystemContext* context) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 InitializeSyncFileSystemService(url.origin(), initialize_callback); 135 InitializeSyncFileSystemService(url.origin(), initialize_callback);
136 } 136 }
137 137
138 storage::AsyncFileUtil* SyncFileSystemBackend::GetAsyncFileUtil( 138 storage::AsyncFileUtil* SyncFileSystemBackend::GetAsyncFileUtil(
139 storage::FileSystemType type) { 139 storage::FileSystemType type) {
140 return GetDelegate()->file_util(); 140 return GetDelegate()->file_util();
141 } 141 }
142 142
143 storage::WatcherManager* SyncFileSystemBackend::GetWatcherManager( 143 storage::WatcherManager* SyncFileSystemBackend::GetWatcherManager(
144 storage::FileSystemType type) { 144 storage::FileSystemType type) {
145 return NULL; 145 return nullptr;
146 } 146 }
147 147
148 storage::CopyOrMoveFileValidatorFactory* 148 storage::CopyOrMoveFileValidatorFactory*
149 SyncFileSystemBackend::GetCopyOrMoveFileValidatorFactory( 149 SyncFileSystemBackend::GetCopyOrMoveFileValidatorFactory(
150 storage::FileSystemType type, 150 storage::FileSystemType type,
151 base::File::Error* error_code) { 151 base::File::Error* error_code) {
152 DCHECK(error_code); 152 DCHECK(error_code);
153 *error_code = base::File::FILE_OK; 153 *error_code = base::File::FILE_OK;
154 return NULL; 154 return nullptr;
155 } 155 }
156 156
157 storage::FileSystemOperation* SyncFileSystemBackend::CreateFileSystemOperation( 157 storage::FileSystemOperation* SyncFileSystemBackend::CreateFileSystemOperation(
158 const storage::FileSystemURL& url, 158 const storage::FileSystemURL& url,
159 storage::FileSystemContext* context, 159 storage::FileSystemContext* context,
160 base::File::Error* error_code) const { 160 base::File::Error* error_code) const {
161 DCHECK(CanHandleType(url.type())); 161 DCHECK(CanHandleType(url.type()));
162 DCHECK(context); 162 DCHECK(context);
163 DCHECK(error_code); 163 DCHECK(error_code);
164 164
165 scoped_ptr<storage::FileSystemOperationContext> operation_context = 165 scoped_ptr<storage::FileSystemOperationContext> operation_context =
166 GetDelegate()->CreateFileSystemOperationContext(url, context, error_code); 166 GetDelegate()->CreateFileSystemOperationContext(url, context, error_code);
167 if (!operation_context) 167 if (!operation_context)
168 return NULL; 168 return nullptr;
169 169
170 if (url.type() == storage::kFileSystemTypeSyncableForInternalSync) { 170 if (url.type() == storage::kFileSystemTypeSyncableForInternalSync) {
171 return storage::FileSystemOperation::Create( 171 return storage::FileSystemOperation::Create(
172 url, context, operation_context.Pass()); 172 url, context, operation_context.Pass());
173 } 173 }
174 174
175 return new SyncableFileSystemOperation( 175 return new SyncableFileSystemOperation(
176 url, context, operation_context.Pass()); 176 url, context, operation_context.Pass());
177 } 177 }
178 178
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 SyncStatusCodeToFileError(status)); 314 SyncStatusCodeToFileError(status));
315 return; 315 return;
316 } 316 }
317 317
318 callback.Run(GetSyncableFileSystemRootURI(origin_url), 318 callback.Run(GetSyncableFileSystemRootURI(origin_url),
319 GetFileSystemName(origin_url, type), 319 GetFileSystemName(origin_url, type),
320 base::File::FILE_OK); 320 base::File::FILE_OK);
321 } 321 }
322 322
323 } // namespace sync_file_system 323 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698