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

Side by Side Diff: components/sync_driver/non_blocking_data_type_manager.cc

Issue 1096983002: Update usages of std::map to use ScopedPtrMap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@passwordmanager-scopedmemory
Patch Set: Rebase. Created 5 years, 6 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
« no previous file with comments | « components/sync_driver/non_blocking_data_type_manager.h ('k') | media/midi/midi_manager_alsa.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "components/sync_driver/non_blocking_data_type_manager.h" 5 #include "components/sync_driver/non_blocking_data_type_manager.h"
6 6
7 #include "base/sequenced_task_runner.h" 7 #include "base/sequenced_task_runner.h"
8 #include "components/sync_driver/non_blocking_data_type_controller.h" 8 #include "components/sync_driver/non_blocking_data_type_controller.h"
9 #include "sync/engine/model_type_sync_proxy_impl.h" 9 #include "sync/engine/model_type_sync_proxy_impl.h"
10 10
11 namespace sync_driver { 11 namespace sync_driver {
12 12
13 NonBlockingDataTypeManager::NonBlockingDataTypeManager() 13 NonBlockingDataTypeManager::NonBlockingDataTypeManager() {
14 : non_blocking_data_type_controllers_deleter_( 14 }
15 &non_blocking_data_type_controllers_) {}
16 15
17 NonBlockingDataTypeManager::~NonBlockingDataTypeManager() {} 16 NonBlockingDataTypeManager::~NonBlockingDataTypeManager() {
17 }
18 18
19 void NonBlockingDataTypeManager::RegisterType( 19 void NonBlockingDataTypeManager::RegisterType(
20 syncer::ModelType type, 20 syncer::ModelType type,
21 bool enabled) { 21 bool enabled) {
22 DCHECK_EQ(0U, non_blocking_data_type_controllers_.count(type)) 22 DCHECK_EQ(0U, non_blocking_data_type_controllers_.count(type))
23 << "Duplicate registration of type " << ModelTypeToString(type); 23 << "Duplicate registration of type " << ModelTypeToString(type);
24 24
25 non_blocking_data_type_controllers_.insert(std::make_pair( 25 non_blocking_data_type_controllers_.insert(
26 type, 26 type, make_scoped_ptr(new NonBlockingDataTypeController(type, enabled)));
27 new NonBlockingDataTypeController(
28 type,
29 enabled)));
30 } 27 }
31 28
32 void NonBlockingDataTypeManager::InitializeType( 29 void NonBlockingDataTypeManager::InitializeType(
33 syncer::ModelType type, 30 syncer::ModelType type,
34 const scoped_refptr<base::SequencedTaskRunner>& task_runner, 31 const scoped_refptr<base::SequencedTaskRunner>& task_runner,
35 const base::WeakPtr<syncer::ModelTypeSyncProxyImpl>& proxy_impl) { 32 const base::WeakPtr<syncer::ModelTypeSyncProxyImpl>& proxy_impl) {
36 NonBlockingDataTypeControllerMap::iterator it = 33 NonBlockingDataTypeControllerMap::const_iterator it =
37 non_blocking_data_type_controllers_.find(type); 34 non_blocking_data_type_controllers_.find(type);
38 DCHECK(it != non_blocking_data_type_controllers_.end()); 35 DCHECK(it != non_blocking_data_type_controllers_.end());
39 it->second->InitializeType(task_runner, proxy_impl); 36 it->second->InitializeType(task_runner, proxy_impl);
40 } 37 }
41 38
42 void NonBlockingDataTypeManager::ConnectSyncBackend( 39 void NonBlockingDataTypeManager::ConnectSyncBackend(
43 scoped_ptr<syncer::SyncContextProxy> proxy) { 40 scoped_ptr<syncer::SyncContextProxy> proxy) {
44 for (NonBlockingDataTypeControllerMap::iterator it = 41 for (NonBlockingDataTypeControllerMap::const_iterator it =
45 non_blocking_data_type_controllers_.begin(); 42 non_blocking_data_type_controllers_.begin();
46 it != non_blocking_data_type_controllers_.end(); ++it) { 43 it != non_blocking_data_type_controllers_.end(); ++it) {
47 it->second->InitializeSyncContext(proxy->Clone()); 44 it->second->InitializeSyncContext(proxy->Clone());
48 } 45 }
49 } 46 }
50 47
51 void NonBlockingDataTypeManager::DisconnectSyncBackend() { 48 void NonBlockingDataTypeManager::DisconnectSyncBackend() {
52 for (NonBlockingDataTypeControllerMap::iterator it = 49 for (NonBlockingDataTypeControllerMap::const_iterator it =
53 non_blocking_data_type_controllers_.begin(); 50 non_blocking_data_type_controllers_.begin();
54 it != non_blocking_data_type_controllers_.end(); ++it) { 51 it != non_blocking_data_type_controllers_.end(); ++it) {
55 it->second->ClearSyncContext(); 52 it->second->ClearSyncContext();
56 } 53 }
57 } 54 }
58 55
59 void NonBlockingDataTypeManager::SetPreferredTypes( 56 void NonBlockingDataTypeManager::SetPreferredTypes(
60 syncer::ModelTypeSet preferred_types) { 57 syncer::ModelTypeSet preferred_types) {
61 for (NonBlockingDataTypeControllerMap::iterator it = 58 for (NonBlockingDataTypeControllerMap::const_iterator it =
62 non_blocking_data_type_controllers_.begin(); 59 non_blocking_data_type_controllers_.begin();
63 it != non_blocking_data_type_controllers_.end(); ++it) { 60 it != non_blocking_data_type_controllers_.end(); ++it) {
64 it->second->SetIsPreferred(preferred_types.Has(it->first)); 61 it->second->SetIsPreferred(preferred_types.Has(it->first));
65 } 62 }
66 } 63 }
67 64
68 syncer::ModelTypeSet NonBlockingDataTypeManager::GetRegisteredTypes() const { 65 syncer::ModelTypeSet NonBlockingDataTypeManager::GetRegisteredTypes() const {
69 syncer::ModelTypeSet result; 66 syncer::ModelTypeSet result;
70 for (NonBlockingDataTypeControllerMap::const_iterator it = 67 for (NonBlockingDataTypeControllerMap::const_iterator it =
71 non_blocking_data_type_controllers_.begin(); 68 non_blocking_data_type_controllers_.begin();
72 it != non_blocking_data_type_controllers_.end(); ++it) { 69 it != non_blocking_data_type_controllers_.end(); ++it) {
73 result.Put(it->first); 70 result.Put(it->first);
74 } 71 }
75 return result; 72 return result;
76 } 73 }
77 74
78 } // namespace sync_driver 75 } // namespace sync_driver
OLDNEW
« no previous file with comments | « components/sync_driver/non_blocking_data_type_manager.h ('k') | media/midi/midi_manager_alsa.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698