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

Side by Side Diff: components/wifi_sync/wifi_credential_syncable_service.h

Issue 1917673002: Convert //components/[u-z]* from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 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 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 #ifndef COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_SYNCABLE_SERVICE_H_ 5 #ifndef COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_SYNCABLE_SERVICE_H_
6 #define COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_SYNCABLE_SERVICE_H_ 6 #define COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_SYNCABLE_SERVICE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory>
9 #include <string> 10 #include <string>
10 #include <utility> 11 #include <utility>
11 12
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "components/keyed_service/core/keyed_service.h" 14 #include "components/keyed_service/core/keyed_service.h"
15 #include "components/wifi_sync/wifi_config_delegate.h" 15 #include "components/wifi_sync/wifi_config_delegate.h"
16 #include "components/wifi_sync/wifi_credential.h" 16 #include "components/wifi_sync/wifi_credential.h"
17 #include "components/wifi_sync/wifi_security_class.h" 17 #include "components/wifi_sync/wifi_security_class.h"
18 #include "sync/api/sync_change_processor.h" 18 #include "sync/api/sync_change_processor.h"
19 #include "sync/api/syncable_service.h" 19 #include "sync/api/syncable_service.h"
20 20
21 namespace wifi_sync { 21 namespace wifi_sync {
22 22
23 // KeyedService that synchronizes WiFi credentials between local settings, 23 // KeyedService that synchronizes WiFi credentials between local settings,
24 // and Chrome Sync. 24 // and Chrome Sync.
25 // 25 //
26 // This service does not necessarily own the storage for WiFi 26 // This service does not necessarily own the storage for WiFi
27 // credentials. In particular, on ChromeOS, WiFi credential storage is 27 // credentials. In particular, on ChromeOS, WiFi credential storage is
28 // managed by the ChromeOS connection manager ("Shill"). 28 // managed by the ChromeOS connection manager ("Shill").
29 // 29 //
30 // On ChromeOS, this class should only be instantiated 30 // On ChromeOS, this class should only be instantiated
31 // for the primary user profile, as that is the only profile for 31 // for the primary user profile, as that is the only profile for
32 // which a Shill profile is loaded. 32 // which a Shill profile is loaded.
33 class WifiCredentialSyncableService 33 class WifiCredentialSyncableService
34 : public syncer::SyncableService, public KeyedService { 34 : public syncer::SyncableService, public KeyedService {
35 public: 35 public:
36 // Constructs a syncable service. Changes from Chrome Sync will be 36 // Constructs a syncable service. Changes from Chrome Sync will be
37 // applied locally by |network_config_delegate|. Local changes will 37 // applied locally by |network_config_delegate|. Local changes will
38 // be propagated to Chrome Sync using the |sync_processor| provided 38 // be propagated to Chrome Sync using the |sync_processor| provided
39 // in the call to MergeDataAndStartSyncing. 39 // in the call to MergeDataAndStartSyncing.
40 explicit WifiCredentialSyncableService( 40 explicit WifiCredentialSyncableService(
41 scoped_ptr<WifiConfigDelegate> network_config_delegate); 41 std::unique_ptr<WifiConfigDelegate> network_config_delegate);
42 ~WifiCredentialSyncableService() override; 42 ~WifiCredentialSyncableService() override;
43 43
44 // syncer::SyncableService implementation. 44 // syncer::SyncableService implementation.
45 syncer::SyncMergeResult MergeDataAndStartSyncing( 45 syncer::SyncMergeResult MergeDataAndStartSyncing(
46 syncer::ModelType type, 46 syncer::ModelType type,
47 const syncer::SyncDataList& initial_sync_data, 47 const syncer::SyncDataList& initial_sync_data,
48 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, 48 std::unique_ptr<syncer::SyncChangeProcessor> sync_processor,
49 scoped_ptr<syncer::SyncErrorFactory> error_handler) override; 49 std::unique_ptr<syncer::SyncErrorFactory> error_handler) override;
50 void StopSyncing(syncer::ModelType type) override; 50 void StopSyncing(syncer::ModelType type) override;
51 syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override; 51 syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override;
52 syncer::SyncError ProcessSyncChanges( 52 syncer::SyncError ProcessSyncChanges(
53 const tracked_objects::Location& caller_location, 53 const tracked_objects::Location& caller_location,
54 const syncer::SyncChangeList& change_list) override; 54 const syncer::SyncChangeList& change_list) override;
55 55
56 // Adds a WiFiCredential to Chrome Sync. |item_id| is a persistent 56 // Adds a WiFiCredential to Chrome Sync. |item_id| is a persistent
57 // identifier which can be used to later remove the credential. It 57 // identifier which can be used to later remove the credential. It
58 // is an error to add a network that already exists. It is also an 58 // is an error to add a network that already exists. It is also an
59 // error to call this method before MergeDataAndStartSyncing(), or 59 // error to call this method before MergeDataAndStartSyncing(), or
60 // after StopSyncing(). 60 // after StopSyncing().
61 // 61 //
62 // TODO(quiche): Allow changing a credential, by addding it again. 62 // TODO(quiche): Allow changing a credential, by addding it again.
63 // crbug.com/431436 63 // crbug.com/431436
64 bool AddToSyncedNetworks(const std::string& item_id, 64 bool AddToSyncedNetworks(const std::string& item_id,
65 const WifiCredential& credential); 65 const WifiCredential& credential);
66 66
67 private: 67 private:
68 using SsidAndSecurityClass = 68 using SsidAndSecurityClass =
69 std::pair<WifiCredential::SsidBytes, WifiSecurityClass>; 69 std::pair<WifiCredential::SsidBytes, WifiSecurityClass>;
70 using SsidAndSecurityClassToPassphrase = 70 using SsidAndSecurityClassToPassphrase =
71 std::map<SsidAndSecurityClass, std::string>; 71 std::map<SsidAndSecurityClass, std::string>;
72 72
73 // The syncer::ModelType that this SyncableService processes and 73 // The syncer::ModelType that this SyncableService processes and
74 // generates updates for. 74 // generates updates for.
75 static const syncer::ModelType kModelType; 75 static const syncer::ModelType kModelType;
76 76
77 // The object we use to change local network configuration. 77 // The object we use to change local network configuration.
78 const scoped_ptr<WifiConfigDelegate> network_config_delegate_; 78 const std::unique_ptr<WifiConfigDelegate> network_config_delegate_;
79 79
80 // Our SyncChangeProcessor instance. Used to push changes into 80 // Our SyncChangeProcessor instance. Used to push changes into
81 // Chrome Sync. 81 // Chrome Sync.
82 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; 82 std::unique_ptr<syncer::SyncChangeProcessor> sync_processor_;
83 83
84 // The networks and passphrases that are already known by Chrome 84 // The networks and passphrases that are already known by Chrome
85 // Sync. All synced networks must be included in this map, even if 85 // Sync. All synced networks must be included in this map, even if
86 // they do not use passphrases. 86 // they do not use passphrases.
87 SsidAndSecurityClassToPassphrase synced_networks_and_passphrases_; 87 SsidAndSecurityClassToPassphrase synced_networks_and_passphrases_;
88 88
89 DISALLOW_COPY_AND_ASSIGN(WifiCredentialSyncableService); 89 DISALLOW_COPY_AND_ASSIGN(WifiCredentialSyncableService);
90 }; 90 };
91 91
92 } // namespace wifi_sync 92 } // namespace wifi_sync
93 93
94 #endif // COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_SYNCABLE_SERVICE_H_ 94 #endif // COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_SYNCABLE_SERVICE_H_
OLDNEW
« no previous file with comments | « components/wifi_sync/wifi_credential.cc ('k') | components/wifi_sync/wifi_credential_syncable_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698