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

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

Issue 2466523002: Remove some linked_ptr c/b/extension (Closed)
Patch Set: Created 4 years, 1 month 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/sync_storage_backend.h" 5 #include "chrome/browser/extensions/api/storage/sync_storage_backend.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 82 }
83 83
84 std::unique_ptr<SettingsStorageQuotaEnforcer> storage( 84 std::unique_ptr<SettingsStorageQuotaEnforcer> storage(
85 new SettingsStorageQuotaEnforcer( 85 new SettingsStorageQuotaEnforcer(
86 quota_, storage_factory_->CreateSettingsStore( 86 quota_, storage_factory_->CreateSettingsStore(
87 settings_namespace::SYNC, ToFactoryModelType(sync_type_), 87 settings_namespace::SYNC, ToFactoryModelType(sync_type_),
88 extension_id))); 88 extension_id)));
89 89
90 // It's fine to create the quota enforcer underneath the sync layer, since 90 // It's fine to create the quota enforcer underneath the sync layer, since
91 // sync will only go ahead if each underlying storage operation succeeds. 91 // sync will only go ahead if each underlying storage operation succeeds.
92 linked_ptr<SyncableSettingsStorage> syncable_storage( 92 storage_objs_[extension_id] = base::MakeUnique<SyncableSettingsStorage>(
93 new SyncableSettingsStorage( 93 observers_, extension_id, storage.release(), sync_type_, flare_);
94 observers_, extension_id, storage.release(), sync_type_, flare_)); 94 SyncableSettingsStorage* syncable_storage = storage_objs_[extension_id].get();
Devlin 2016/11/02 22:25:33 similar comment here around saving a lookup
limasdf 2016/11/03 15:29:23 Done.
95 storage_objs_[extension_id] = syncable_storage;
96 95
97 if (sync_processor_.get()) { 96 if (sync_processor_.get()) {
98 syncer::SyncError error = syncable_storage->StartSyncing( 97 syncer::SyncError error = syncable_storage->StartSyncing(
99 std::move(sync_data), CreateSettingsSyncProcessor(extension_id)); 98 std::move(sync_data), CreateSettingsSyncProcessor(extension_id));
100 if (error.IsSet()) 99 if (error.IsSet())
101 syncable_storage->StopSyncing(); 100 syncable_storage->StopSyncing();
102 } 101 }
103 return syncable_storage.get(); 102 return syncable_storage;
104 } 103 }
105 104
106 void SyncStorageBackend::DeleteStorage(const std::string& extension_id) { 105 void SyncStorageBackend::DeleteStorage(const std::string& extension_id) {
107 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 106 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
108 107
109 // Clear settings when the extension is uninstalled. Leveldb implementations 108 // Clear settings when the extension is uninstalled. Leveldb implementations
110 // will also delete the database from disk when the object is destroyed as a 109 // will also delete the database from disk when the object is destroyed as a
111 // result of being removed from |storage_objs_|. 110 // result of being removed from |storage_objs_|.
112 // 111 //
113 // TODO(kalman): always GetStorage here (rather than only clearing if it 112 // TODO(kalman): always GetStorage here (rather than only clearing if it
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 274
276 std::unique_ptr<SettingsSyncProcessor> 275 std::unique_ptr<SettingsSyncProcessor>
277 SyncStorageBackend::CreateSettingsSyncProcessor( 276 SyncStorageBackend::CreateSettingsSyncProcessor(
278 const std::string& extension_id) const { 277 const std::string& extension_id) const {
279 CHECK(sync_processor_.get()); 278 CHECK(sync_processor_.get());
280 return std::unique_ptr<SettingsSyncProcessor>(new SettingsSyncProcessor( 279 return std::unique_ptr<SettingsSyncProcessor>(new SettingsSyncProcessor(
281 extension_id, sync_type_, sync_processor_.get())); 280 extension_id, sync_type_, sync_processor_.get()));
282 } 281 }
283 282
284 } // namespace extensions 283 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698