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

Side by Side Diff: chrome/browser/extensions/api/storage/settings_backend.cc

Issue 138073006: sync: fix the way extension/app settings trigger deferred sync init (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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/extensions/api/storage/settings_backend.h" 5 #include "chrome/browser/extensions/api/storage/settings_backend.h"
6 6
7 #include "base/files/file_enumerator.h" 7 #include "base/files/file_enumerator.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "chrome/browser/extensions/api/storage/settings_sync_processor.h" 9 #include "chrome/browser/extensions/api/storage/settings_sync_processor.h"
10 #include "chrome/browser/extensions/api/storage/settings_sync_util.h" 10 #include "chrome/browser/extensions/api/storage/settings_sync_util.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 CHECK(storage); 59 CHECK(storage);
60 60
61 // It's fine to create the quota enforcer underneath the sync layer, since 61 // It's fine to create the quota enforcer underneath the sync layer, since
62 // sync will only go ahead if each underlying storage operation succeeds. 62 // sync will only go ahead if each underlying storage operation succeeds.
63 storage = new SettingsStorageQuotaEnforcer(quota_, storage); 63 storage = new SettingsStorageQuotaEnforcer(quota_, storage);
64 64
65 linked_ptr<SyncableSettingsStorage> syncable_storage( 65 linked_ptr<SyncableSettingsStorage> syncable_storage(
66 new SyncableSettingsStorage( 66 new SyncableSettingsStorage(
67 observers_, 67 observers_,
68 extension_id, 68 extension_id,
69 storage)); 69 storage,
70 sync_type_,
71 flare_));
70 storage_objs_[extension_id] = syncable_storage; 72 storage_objs_[extension_id] = syncable_storage;
71 73
72 if (sync_processor_.get()) { 74 if (sync_processor_.get()) {
73 syncer::SyncError error = 75 syncer::SyncError error =
74 syncable_storage->StartSyncing( 76 syncable_storage->StartSyncing(
75 sync_data, 77 sync_data,
76 CreateSettingsSyncProcessor(extension_id).Pass()); 78 CreateSettingsSyncProcessor(extension_id).Pass());
77 if (error.IsSet()) 79 if (error.IsSet())
78 syncable_storage.get()->StopSyncing(); 80 syncable_storage.get()->StopSyncing();
79 } else {
80 // Tell sync to try and start soon, because syncable changes to sync_type_
81 // have started happening. This will cause sync to call us back
82 // asynchronously via MergeDataAndStartSyncing as soon as possible.
83 flare_.Run(sync_type_);
84 } 81 }
85
86 return syncable_storage.get(); 82 return syncable_storage.get();
87 } 83 }
88 84
89 void SettingsBackend::DeleteStorage(const std::string& extension_id) { 85 void SettingsBackend::DeleteStorage(const std::string& extension_id) {
90 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 86 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
91 87
92 // Clear settings when the extension is uninstalled. Leveldb implementations 88 // Clear settings when the extension is uninstalled. Leveldb implementations
93 // will also delete the database from disk when the object is destroyed as a 89 // will also delete the database from disk when the object is destroyed as a
94 // result of being removed from |storage_objs_|. 90 // result of being removed from |storage_objs_|.
95 // 91 //
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 scoped_ptr<SettingsSyncProcessor> SettingsBackend::CreateSettingsSyncProcessor( 277 scoped_ptr<SettingsSyncProcessor> SettingsBackend::CreateSettingsSyncProcessor(
282 const std::string& extension_id) const { 278 const std::string& extension_id) const {
283 CHECK(sync_processor_.get()); 279 CHECK(sync_processor_.get());
284 return scoped_ptr<SettingsSyncProcessor>( 280 return scoped_ptr<SettingsSyncProcessor>(
285 new SettingsSyncProcessor(extension_id, 281 new SettingsSyncProcessor(extension_id,
286 sync_type_, 282 sync_type_,
287 sync_processor_.get())); 283 sync_processor_.get()));
288 } 284 }
289 285
290 } // namespace extensions 286 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698