Chromium Code Reviews| Index: components/wifi_sync/wifi_credential_syncable_service.h |
| diff --git a/components/wifi_sync/wifi_credential_syncable_service.h b/components/wifi_sync/wifi_credential_syncable_service.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..582b3f219528151b6a3b0295d0fb7b662673680c |
| --- /dev/null |
| +++ b/components/wifi_sync/wifi_credential_syncable_service.h |
| @@ -0,0 +1,80 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_SYNCABLE_SERVICE_H_ |
| +#define COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_SYNCABLE_SERVICE_H_ |
| + |
| +#include <set> |
| +#include <string> |
| +#include <utility> // for std::pair |
| +#include <vector> |
| + |
| +#include "base/macros.h" |
| +#include "base/threading/thread_checker.h" |
| +#include "components/keyed_service/core/keyed_service.h" |
| +#include "components/wifi_sync/wifi_security_class.h" |
| +#include "sync/api/sync_data.h" |
| +#include "sync/api/sync_error.h" |
| +#include "sync/api/sync_error_factory.h" |
| +#include "sync/api/syncable_service.h" |
| + |
| +namespace content { |
| +class BrowserContext; |
| +} // content |
| + |
| +namespace wifi_sync { |
| + |
| +// KeyedService that synchronizes WiFi credentials between local settings, |
| +// and Chrome Sync. |
| +// |
| +// This service does not necessarily own the storage for WiFi |
| +// credentials. In particular, on ChromeOS, WiFi credential storage is |
| +// managed by the ChromeOS connection manager ("shill"). |
|
stevenjb
2014/11/12 21:30:44
nit: Shill
mukesh agrawal
2014/11/13 16:24:58
Done.
|
| +class WifiCredentialSyncableService |
| + : public syncer::SyncableService, public KeyedService { |
| + public: |
| + // Construct a service for the given |context|. Local changes will |
|
stevenjb
2014/11/12 21:30:44
Constructs
mukesh agrawal
2014/11/13 16:24:58
Done.
|
| + // be applied to the Chrome Sync data for the user associated with |
| + // |context|. |
| + explicit WifiCredentialSyncableService(content::BrowserContext *context); |
| + ~WifiCredentialSyncableService() override; |
| + |
| + // syncer::SyncableService implementation. |
| + syncer::SyncMergeResult MergeDataAndStartSyncing( |
| + syncer::ModelType type, |
| + const syncer::SyncDataList& initial_sync_data, |
| + scoped_ptr<syncer::SyncChangeProcessor> sync_processor, |
| + scoped_ptr<syncer::SyncErrorFactory> error_handler) override; |
| + void StopSyncing(syncer::ModelType type) override; |
|
stevenjb
2014/11/12 21:30:44
WS
mukesh agrawal
2014/11/13 16:24:58
Sorry, I don't understand. What's normal practice
stevenjb
2014/11/13 22:55:35
So, normally overridden methods are not commented,
mukesh agrawal
2014/11/14 02:14:54
Done.
Since the base class has many subclasses, I
|
| + // The implementation of GetAllSyncData may not actually return the |
| + // complete data list. In particular, the ChromeOS implementation |
| + // will return an empty list. |
| + syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override; |
| + syncer::SyncError ProcessSyncChanges( |
| + const tracked_objects::Location& from_here, |
| + const syncer::SyncChangeList& change_list) override; |
| + |
| + // Test support. |
| + std::set<std::pair<std::vector<char>, WifiSecurityClass>> |
|
stevenjb
2014/11/12 21:30:44
Maybe typedef this (with 'using')?
mukesh agrawal
2014/11/13 16:24:58
Can do. Do we prefer something abstract (e.g. "Wif
stevenjb
2014/11/13 22:55:35
I'd split the difference, e.g. WifiSsidSecuritySet
mukesh agrawal
2014/11/14 02:14:53
Done.
|
| + GetWifiNetworksForTest() const; |
| + |
| + private: |
| + friend class WifiCredentialSyncableServiceTest; |
| + |
| + static const enum syncer::ModelType kModelType; |
| + |
| + // Const members. |
| + const content::BrowserContext* const browser_context_; |
| + const base::ThreadChecker thread_checker_; |
| + |
| + // Non-const members. |
| + scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; |
| + scoped_ptr<syncer::SyncErrorFactory> sync_error_handler_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(WifiCredentialSyncableService); |
| +}; |
| + |
| +} // namespace wifi_sync |
| + |
| +#endif // COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_SYNCABLE_SERVICE_H_ |