Android: Put GPU process in foreground
[chromium-blink-merge.git] / components / wifi_sync / wifi_credential_syncable_service.h
blobd0868e8ba1cf057e90a4e27ae623f8436a0becd0
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_SYNCABLE_SERVICE_H_
6 #define COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_SYNCABLE_SERVICE_H_
8 #include <string>
10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "components/keyed_service/core/keyed_service.h"
13 #include "components/wifi_sync/wifi_config_delegate.h"
14 #include "sync/api/sync_change_processor.h"
15 #include "sync/api/syncable_service.h"
17 namespace wifi_sync {
18 class WifiCredential;
20 // KeyedService that synchronizes WiFi credentials between local settings,
21 // and Chrome Sync.
23 // This service does not necessarily own the storage for WiFi
24 // credentials. In particular, on ChromeOS, WiFi credential storage is
25 // managed by the ChromeOS connection manager ("Shill").
27 // On ChromeOS, this class should only be instantiated
28 // for the primary user profile, as that is the only profile for
29 // which a Shill profile is loaded.
30 class WifiCredentialSyncableService
31 : public syncer::SyncableService, public KeyedService {
32 public:
33 // Constructs a syncable service. Changes from Chrome Sync will be
34 // applied locally by |network_config_delegate|. Local changes will
35 // be propagated to Chrome Sync using the |sync_processor| provided
36 // in the call to MergeDataAndStartSyncing.
37 explicit WifiCredentialSyncableService(
38 scoped_ptr<WifiConfigDelegate> network_config_delegate);
39 ~WifiCredentialSyncableService() override;
41 // syncer::SyncableService implementation.
42 syncer::SyncMergeResult MergeDataAndStartSyncing(
43 syncer::ModelType type,
44 const syncer::SyncDataList& initial_sync_data,
45 scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
46 scoped_ptr<syncer::SyncErrorFactory> error_handler) override;
47 void StopSyncing(syncer::ModelType type) override;
48 syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override;
49 syncer::SyncError ProcessSyncChanges(
50 const tracked_objects::Location& caller_location,
51 const syncer::SyncChangeList& change_list) override;
53 // Adds a WiFiCredential to Chrome Sync. |item_id| is a persistent
54 // identifier which can be used to later remove the credential. It
55 // is an error to add a network that already exists. It is also an
56 // error to call this method before MergeDataAndStartSyncing(), or
57 // after StopSyncing().
59 // TODO(quiche): Allow changing a credential, by addding it again.
60 // crbug.com/431436
61 bool AddToSyncedNetworks(const std::string& item_id,
62 const WifiCredential& credential);
64 private:
65 // The syncer::ModelType that this SyncableService processes and
66 // generates updates for.
67 static const syncer::ModelType kModelType;
69 // The object we use to change local network configuration.
70 const scoped_ptr<WifiConfigDelegate> network_config_delegate_;
72 // Our SyncChangeProcessor instance. Used to push changes into
73 // Chrome Sync.
74 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_;
76 DISALLOW_COPY_AND_ASSIGN(WifiCredentialSyncableService);
79 } // namespace wifi_sync
81 #endif // COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_SYNCABLE_SERVICE_H_