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

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: review 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 SyncableSettingsStorage* SyncStorageBackend::GetOrCreateStorageWithSyncData( 74 SyncableSettingsStorage* SyncStorageBackend::GetOrCreateStorageWithSyncData(
75 const std::string& extension_id, 75 const std::string& extension_id,
76 std::unique_ptr<base::DictionaryValue> sync_data) const { 76 std::unique_ptr<base::DictionaryValue> sync_data) const {
77 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 77 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
78 78
79 StorageObjMap::iterator maybe_storage = storage_objs_.find(extension_id); 79 StorageObjMap::iterator maybe_storage = storage_objs_.find(extension_id);
80 if (maybe_storage != storage_objs_.end()) { 80 if (maybe_storage != storage_objs_.end()) {
81 return maybe_storage->second.get(); 81 return maybe_storage->second.get();
82 } 82 }
83 83
84 std::unique_ptr<SettingsStorageQuotaEnforcer> storage( 84 std::unique_ptr<SettingsStorageQuotaEnforcer> settings_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 std::unique_ptr<SyncableSettingsStorage> syncable_storage(
93 new SyncableSettingsStorage( 93 new SyncableSettingsStorage(observers_, extension_id,
94 observers_, extension_id, storage.release(), sync_type_, flare_)); 94 settings_storage.release(), sync_type_,
95 storage_objs_[extension_id] = syncable_storage; 95 flare_));
96 SyncableSettingsStorage* raw_syncable_storage = syncable_storage.get();
97 storage_objs_[extension_id] = std::move(syncable_storage);
96 98
97 if (sync_processor_.get()) { 99 if (sync_processor_.get()) {
98 syncer::SyncError error = syncable_storage->StartSyncing( 100 syncer::SyncError error = raw_syncable_storage->StartSyncing(
99 std::move(sync_data), CreateSettingsSyncProcessor(extension_id)); 101 std::move(sync_data), CreateSettingsSyncProcessor(extension_id));
100 if (error.IsSet()) 102 if (error.IsSet())
101 syncable_storage->StopSyncing(); 103 raw_syncable_storage->StopSyncing();
102 } 104 }
103 return syncable_storage.get(); 105 return raw_syncable_storage;
104 } 106 }
105 107
106 void SyncStorageBackend::DeleteStorage(const std::string& extension_id) { 108 void SyncStorageBackend::DeleteStorage(const std::string& extension_id) {
107 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 109 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
108 110
109 // Clear settings when the extension is uninstalled. Leveldb implementations 111 // Clear settings when the extension is uninstalled. Leveldb implementations
110 // will also delete the database from disk when the object is destroyed as a 112 // will also delete the database from disk when the object is destroyed as a
111 // result of being removed from |storage_objs_|. 113 // result of being removed from |storage_objs_|.
112 // 114 //
113 // TODO(kalman): always GetStorage here (rather than only clearing if it 115 // TODO(kalman): always GetStorage here (rather than only clearing if it
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 277
276 std::unique_ptr<SettingsSyncProcessor> 278 std::unique_ptr<SettingsSyncProcessor>
277 SyncStorageBackend::CreateSettingsSyncProcessor( 279 SyncStorageBackend::CreateSettingsSyncProcessor(
278 const std::string& extension_id) const { 280 const std::string& extension_id) const {
279 CHECK(sync_processor_.get()); 281 CHECK(sync_processor_.get());
280 return std::unique_ptr<SettingsSyncProcessor>(new SettingsSyncProcessor( 282 return std::unique_ptr<SettingsSyncProcessor>(new SettingsSyncProcessor(
281 extension_id, sync_type_, sync_processor_.get())); 283 extension_id, sync_type_, sync_processor_.get()));
282 } 284 }
283 285
284 } // namespace extensions 286 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698