Move all providers into include/weave/provider BUG: 24267885 Change-Id: I615611609dd26c73bc662e808c27820fe099218c Reviewed-on: https://weave-review.googlesource.com/1171 Reviewed-by: Vitaly Buka <vitalybuka@google.com>
diff --git a/libweave/examples/ubuntu/avahi_client.h b/libweave/examples/ubuntu/avahi_client.h index d3121a9..ed955ec 100644 --- a/libweave/examples/ubuntu/avahi_client.h +++ b/libweave/examples/ubuntu/avahi_client.h
@@ -12,13 +12,13 @@ #include <avahi-client/publish.h> #include <avahi-common/thread-watch.h> -#include <weave/dns_service_discovery_provider.h> +#include <weave/provider/dns_service_discovery.h> namespace weave { namespace examples { -// Example of weave::DnsServiceDiscoveryProvider implemented with avahi. -class AvahiClient : public DnsServiceDiscoveryProvider { +// Example of provider::DnsServiceDiscovery implemented with avahi. +class AvahiClient : public provider::DnsServiceDiscovery { public: AvahiClient();
diff --git a/libweave/examples/ubuntu/bluez_client.h b/libweave/examples/ubuntu/bluez_client.h index 0915403..23e21ad 100644 --- a/libweave/examples/ubuntu/bluez_client.h +++ b/libweave/examples/ubuntu/bluez_client.h
@@ -5,13 +5,13 @@ #ifndef LIBWEAVE_EXAMPLES_UBUNTU_BLUEZ_CLIENT_H_ #define LIBWEAVE_EXAMPLES_UBUNTU_BLUEZ_CLIENT_H_ -#include <weave/bluetooth.h> +#include <weave/provider/bluetooth.h> namespace weave { namespace examples { // Example of weave::Bluetooth implemented with bluez. -class BluetoothImpl : public Bluetooth { +class BluetoothImpl : public provider::Bluetooth { public: BluetoothImpl();
diff --git a/libweave/examples/ubuntu/curl_http_client.cc b/libweave/examples/ubuntu/curl_http_client.cc index 3ab3497..2be12d7 100644 --- a/libweave/examples/ubuntu/curl_http_client.cc +++ b/libweave/examples/ubuntu/curl_http_client.cc
@@ -6,14 +6,14 @@ #include <base/bind.h> #include <curl/curl.h> -#include <weave/task_runner.h> +#include <weave/provider/task_runner.h> namespace weave { namespace examples { namespace { -struct ResponseImpl : public HttpClient::Response { +struct ResponseImpl : public provider::HttpClient::Response { int GetStatusCode() const { return status; } std::string GetContentType() const { return content_type; } const std::string& GetData() const { return data; } @@ -31,15 +31,15 @@ } // namespace -CurlHttpClient::CurlHttpClient(TaskRunner* task_runner) +CurlHttpClient::CurlHttpClient(provider::TaskRunner* task_runner) : task_runner_{task_runner} {} -std::unique_ptr<HttpClient::Response> CurlHttpClient::SendRequestAndBlock( - const std::string& method, - const std::string& url, - const Headers& headers, - const std::string& data, - ErrorPtr* error) { +std::unique_ptr<provider::HttpClient::Response> +CurlHttpClient::SendRequestAndBlock(const std::string& method, + const std::string& url, + const Headers& headers, + const std::string& data, + ErrorPtr* error) { std::unique_ptr<CURL, decltype(&curl_easy_cleanup)> curl{curl_easy_init(), &curl_easy_cleanup}; CHECK(curl);
diff --git a/libweave/examples/ubuntu/curl_http_client.h b/libweave/examples/ubuntu/curl_http_client.h index 45e13dc..853b797 100644 --- a/libweave/examples/ubuntu/curl_http_client.h +++ b/libweave/examples/ubuntu/curl_http_client.h
@@ -8,19 +8,21 @@ #include <string> #include <base/memory/weak_ptr.h> -#include <weave/http_client.h> +#include <weave/provider/http_client.h> namespace weave { +namespace provider { class TaskRunner; +} namespace examples { // Basic implementation of weave::HttpClient using libcurl. Should be used in // production code as it's blocking and does not validate server certificates. -class CurlHttpClient : public HttpClient { +class CurlHttpClient : public provider::HttpClient { public: - explicit CurlHttpClient(TaskRunner* task_runner); + explicit CurlHttpClient(provider::TaskRunner* task_runner); std::unique_ptr<Response> SendRequestAndBlock(const std::string& method, const std::string& url, @@ -42,7 +44,7 @@ int id, ErrorPtr error); - TaskRunner* task_runner_{nullptr}; + provider::TaskRunner* task_runner_{nullptr}; int request_id_ = 0; base::WeakPtrFactory<CurlHttpClient> weak_ptr_factory_{this};
diff --git a/libweave/examples/ubuntu/event_http_server.cc b/libweave/examples/ubuntu/event_http_server.cc index 8e45648..fff49cd 100644 --- a/libweave/examples/ubuntu/event_http_server.cc +++ b/libweave/examples/ubuntu/event_http_server.cc
@@ -32,7 +32,8 @@ class MemoryReadStream : public Stream { public: - MemoryReadStream(const std::vector<uint8_t>& data, TaskRunner* task_runner) + MemoryReadStream(const std::vector<uint8_t>& data, + provider::TaskRunner* task_runner) : data_{data}, task_runner_{task_runner} {} void Read(void* buffer, @@ -58,7 +59,7 @@ private: const std::vector<uint8_t>& data_; - TaskRunner* task_runner_; + provider::TaskRunner* task_runner_; size_t read_position_{0}; }; @@ -66,7 +67,7 @@ class HttpServerImpl::RequestImpl : public Request { public: - explicit RequestImpl(evhttp_request* req, TaskRunner* task_runner) + explicit RequestImpl(evhttp_request* req, provider::TaskRunner* task_runner) : path_{evhttp_request_uri(req)}, task_runner_{task_runner} { path_ = path_.substr(0, path_.find("?")); path_ = path_.substr(0, path_.find("#")); @@ -97,7 +98,7 @@ std::unique_ptr<evhttp_request, decltype(&evhttp_cancel_request)> req_{ nullptr, &evhttp_cancel_request}; std::string path_; - TaskRunner* task_runner_; + provider::TaskRunner* task_runner_; }; HttpServerImpl::HttpServerImpl(EventTaskRunner* task_runner)
diff --git a/libweave/examples/ubuntu/event_http_server.h b/libweave/examples/ubuntu/event_http_server.h index 52dd292..1005edc 100644 --- a/libweave/examples/ubuntu/event_http_server.h +++ b/libweave/examples/ubuntu/event_http_server.h
@@ -14,7 +14,7 @@ #include <vector> #include <base/memory/weak_ptr.h> -#include <weave/http_server.h> +#include <weave/provider/http_server.h> namespace weave { namespace examples { @@ -22,7 +22,7 @@ class EventTaskRunner; // HTTP/HTTPS server implemented with libevent. -class HttpServerImpl : public HttpServer { +class HttpServerImpl : public provider::HttpServer { public: class RequestImpl;
diff --git a/libweave/examples/ubuntu/event_task_runner.h b/libweave/examples/ubuntu/event_task_runner.h index 726a621..3f04995 100644 --- a/libweave/examples/ubuntu/event_task_runner.h +++ b/libweave/examples/ubuntu/event_task_runner.h
@@ -11,13 +11,13 @@ #include <event2/event.h> -#include <weave/task_runner.h> +#include <weave/provider/task_runner.h> namespace weave { namespace examples { // Simple task runner implemented with libevent message loop. -class EventTaskRunner : public TaskRunner { +class EventTaskRunner : public provider::TaskRunner { public: void PostDelayedTask(const tracked_objects::Location& from_here, const base::Closure& task,
diff --git a/libweave/examples/ubuntu/file_config_store.h b/libweave/examples/ubuntu/file_config_store.h index f6e9b5f..e2bd1c1 100644 --- a/libweave/examples/ubuntu/file_config_store.h +++ b/libweave/examples/ubuntu/file_config_store.h
@@ -9,12 +9,12 @@ #include <string> #include <vector> -#include <weave/config_store.h> +#include <weave/provider/config_store.h> namespace weave { namespace examples { -class FileConfigStore : public ConfigStore { +class FileConfigStore : public provider::ConfigStore { public: bool LoadDefaults(Settings* settings) override; std::string LoadSettings() override;
diff --git a/libweave/examples/ubuntu/network_manager.cc b/libweave/examples/ubuntu/network_manager.cc index fc033b5..4f94ef2 100644 --- a/libweave/examples/ubuntu/network_manager.cc +++ b/libweave/examples/ubuntu/network_manager.cc
@@ -12,7 +12,7 @@ #include <fstream> #include <base/bind.h> -#include <weave/task_runner.h> +#include <weave/provider/task_runner.h> #include "libweave/examples/ubuntu/ssl_stream.h" @@ -21,6 +21,8 @@ namespace { +using provider::NetworkState; + int ForkCmd(const std::string& path, const std::vector<std::string>& args) { int pid = fork(); if (pid != 0) @@ -38,7 +40,8 @@ } // namespace -NetworkImpl::NetworkImpl(TaskRunner* task_runner, bool force_bootstrapping) +NetworkImpl::NetworkImpl(provider::TaskRunner* task_runner, + bool force_bootstrapping) : task_runner_{task_runner}, force_bootstrapping_{force_bootstrapping} { SSL_load_error_strings(); SSL_library_init();
diff --git a/libweave/examples/ubuntu/network_manager.h b/libweave/examples/ubuntu/network_manager.h index e59bc96..4df2a07 100644 --- a/libweave/examples/ubuntu/network_manager.h +++ b/libweave/examples/ubuntu/network_manager.h
@@ -10,32 +10,35 @@ #include <base/memory/weak_ptr.h> #include <base/time/time.h> -#include <weave/network_provider.h> -#include <weave/wifi_provider.h> +#include <weave/provider/network.h> +#include <weave/provider/wifi.h> namespace weave { +namespace provider { class TaskRunner; +} namespace examples { // Basic weave::Network implementation. // Production version of SSL socket needs secure server certificate check. -class NetworkImpl : public NetworkProvider, public WifiProvider { +class NetworkImpl : public provider::Network, public provider::Wifi { public: - explicit NetworkImpl(TaskRunner* task_runner, bool force_bootstrapping); + explicit NetworkImpl(provider::TaskRunner* task_runner, + bool force_bootstrapping); ~NetworkImpl(); - // NetworkProvider implementation. + // Network implementation. void AddConnectionChangedCallback( const ConnectionChangedCallback& callback) override; - NetworkState GetConnectionState() const override; + provider::NetworkState GetConnectionState() const override; void OpenSslSocket(const std::string& host, uint16_t port, const OpenSslSocketSuccessCallback& success_callback, const ErrorCallback& error_callback) override; - // WifiProvider implementation. + // Wifi implementation. void Connect(const std::string& ssid, const std::string& passphrase, const SuccessCallback& success_callback, @@ -56,9 +59,9 @@ bool force_bootstrapping_{false}; bool hostapd_started_{false}; - TaskRunner* task_runner_{nullptr}; + provider::TaskRunner* task_runner_{nullptr}; std::vector<ConnectionChangedCallback> callbacks_; - NetworkState network_state_{NetworkState::kOffline}; + provider::NetworkState network_state_{provider::NetworkState::kOffline}; base::WeakPtrFactory<NetworkImpl> weak_ptr_factory_{this}; };
diff --git a/libweave/examples/ubuntu/ssl_stream.cc b/libweave/examples/ubuntu/ssl_stream.cc index a54578d..920648f 100644 --- a/libweave/examples/ubuntu/ssl_stream.cc +++ b/libweave/examples/ubuntu/ssl_stream.cc
@@ -5,12 +5,13 @@ #include "libweave/examples/ubuntu/ssl_stream.h" #include <base/bind.h> -#include <weave/task_runner.h> +#include <weave/provider/task_runner.h> namespace weave { namespace examples { -SSLStream::SSLStream(TaskRunner* task_runner) : task_runner_{task_runner} {} +SSLStream::SSLStream(provider::TaskRunner* task_runner) + : task_runner_{task_runner} {} SSLStream::~SSLStream() { CancelPendingOperations();
diff --git a/libweave/examples/ubuntu/ssl_stream.h b/libweave/examples/ubuntu/ssl_stream.h index 7343df9..ac0d76a 100644 --- a/libweave/examples/ubuntu/ssl_stream.h +++ b/libweave/examples/ubuntu/ssl_stream.h
@@ -12,13 +12,15 @@ namespace weave { +namespace provider { class TaskRunner; +} namespace examples { class SSLStream : public Stream { public: - explicit SSLStream(TaskRunner* task_runner); + explicit SSLStream(provider::TaskRunner* task_runner); ~SSLStream() override; @@ -39,7 +41,7 @@ private: void RunDelayedTask(const base::Closure& task); - TaskRunner* task_runner_{nullptr}; + provider::TaskRunner* task_runner_{nullptr}; std::unique_ptr<SSL_CTX, decltype(&SSL_CTX_free)> ctx_{nullptr, SSL_CTX_free}; std::unique_ptr<SSL, decltype(&SSL_free)> ssl_{nullptr, SSL_free};
diff --git a/libweave/include/weave/bluetooth.h b/libweave/include/weave/bluetooth.h deleted file mode 100644 index 69fdc5e..0000000 --- a/libweave/include/weave/bluetooth.h +++ /dev/null
@@ -1,20 +0,0 @@ -// Copyright 2015 The Chromium OS 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 LIBWEAVE_INCLUDE_WEAVE_BLUETOOTH_H_ -#define LIBWEAVE_INCLUDE_WEAVE_BLUETOOTH_H_ - -namespace weave { - -class Bluetooth { - public: - // TODO(rginda): Add bluetooth interface methods here. - - protected: - virtual ~Bluetooth() = default; -}; - -} // namespace weave - -#endif // LIBWEAVE_INCLUDE_WEAVE_BLUETOOTH_H_
diff --git a/libweave/include/weave/config_store.h b/libweave/include/weave/config_store.h deleted file mode 100644 index 8a5af58..0000000 --- a/libweave/include/weave/config_store.h +++ /dev/null
@@ -1,72 +0,0 @@ -// Copyright 2015 The Chromium OS 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 LIBWEAVE_INCLUDE_WEAVE_CONFIG_STORE_H_ -#define LIBWEAVE_INCLUDE_WEAVE_CONFIG_STORE_H_ - -#include <map> -#include <set> -#include <string> -#include <vector> - -#include <base/callback.h> -#include <base/time/time.h> -#include <weave/enum_to_string.h> -#include <weave/privet.h> - -namespace weave { - -struct Settings { - std::string client_id; - std::string client_secret; - std::string api_key; - std::string oauth_url; - std::string service_url; - std::string name; - std::string description; - std::string location; - std::string local_anonymous_access_role; - bool local_discovery_enabled{true}; - bool local_pairing_enabled{true}; - std::string firmware_version; - std::string oem_name; - std::string model_name; - std::string model_id; - base::TimeDelta polling_period; - base::TimeDelta backup_polling_period; - - bool wifi_auto_setup_enabled{true}; - bool ble_setup_enabled{false}; - std::set<PairingType> pairing_modes; - std::string embedded_code; - - std::string device_id; - std::string refresh_token; - std::string robot_account; - std::string last_configured_ssid; -}; - -class ConfigStore { - public: - virtual bool LoadDefaults(Settings* settings) = 0; - virtual std::string LoadSettings() = 0; - virtual void SaveSettings(const std::string& settings) = 0; - virtual void OnSettingsChanged(const Settings& settings) = 0; - - virtual std::string LoadBaseCommandDefs() = 0; - virtual std::map<std::string, std::string> LoadCommandDefs() = 0; - - virtual std::string LoadBaseStateDefs() = 0; - virtual std::string LoadBaseStateDefaults() = 0; - - virtual std::map<std::string, std::string> LoadStateDefs() = 0; - virtual std::vector<std::string> LoadStateDefaults() = 0; - - protected: - virtual ~ConfigStore() = default; -}; - -} // namespace weave - -#endif // LIBWEAVE_INCLUDE_WEAVE_CONFIG_STORE_H_
diff --git a/libweave/include/weave/device.h b/libweave/include/weave/device.h index c6b70ea..6d1cd92 100644 --- a/libweave/include/weave/device.h +++ b/libweave/include/weave/device.h
@@ -9,19 +9,19 @@ #include <set> #include <string> -#include <weave/bluetooth.h> #include <weave/cloud.h> #include <weave/commands.h> -#include <weave/config_store.h> -#include <weave/dns_service_discovery_provider.h> #include <weave/export.h> -#include <weave/http_client.h> -#include <weave/http_server.h> -#include <weave/network_provider.h> #include <weave/privet.h> +#include <weave/provider/bluetooth.h> +#include <weave/provider/config_store.h> +#include <weave/provider/dns_service_discovery.h> +#include <weave/provider/http_client.h> +#include <weave/provider/http_server.h> +#include <weave/provider/network.h> +#include <weave/provider/task_runner.h> +#include <weave/provider/wifi.h> #include <weave/state.h> -#include <weave/task_runner.h> -#include <weave/wifi_provider.h> namespace weave { @@ -38,14 +38,14 @@ virtual ~Device() = default; virtual void Start(const Options& options, - ConfigStore* config_store, - TaskRunner* task_runner, - HttpClient* http_client, - NetworkProvider* network, - DnsServiceDiscoveryProvider* dns_sd, - HttpServer* http_server, - WifiProvider* wifi, - Bluetooth* bluetooth) = 0; + provider::ConfigStore* config_store, + provider::TaskRunner* task_runner, + provider::HttpClient* http_client, + provider::Network* network, + provider::DnsServiceDiscovery* dns_sd, + provider::HttpServer* http_server, + provider::Wifi* wifi, + provider::Bluetooth* bluetooth_provider) = 0; virtual Commands* GetCommands() = 0; virtual State* GetState() = 0;
diff --git a/libweave/include/weave/provider/bluetooth.h b/libweave/include/weave/provider/bluetooth.h new file mode 100644 index 0000000..d87dcc0 --- /dev/null +++ b/libweave/include/weave/provider/bluetooth.h
@@ -0,0 +1,23 @@ +// Copyright 2015 The Chromium OS 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 LIBWEAVE_INCLUDE_WEAVE_PROVIDER_BLUETOOTH_H_ +#define LIBWEAVE_INCLUDE_WEAVE_PROVIDER_BLUETOOTH_H_ + +namespace weave { +namespace provider { + +// Interface with methods to control bluetooth capability of the device. +class Bluetooth { + public: + // TODO(rginda): Add bluetooth interface methods here. + + protected: + virtual ~Bluetooth() = default; +}; + +} // namespace provider +} // namespace weave + +#endif // LIBWEAVE_INCLUDE_WEAVE_PROVIDER_BLUETOOTH_H_
diff --git a/libweave/include/weave/provider/config_store.h b/libweave/include/weave/provider/config_store.h new file mode 100644 index 0000000..85cae42 --- /dev/null +++ b/libweave/include/weave/provider/config_store.h
@@ -0,0 +1,44 @@ +// Copyright 2015 The Chromium OS 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 LIBWEAVE_INCLUDE_WEAVE_PROVIDER_CONFIG_STORE_H_ +#define LIBWEAVE_INCLUDE_WEAVE_PROVIDER_CONFIG_STORE_H_ + +#include <map> +#include <set> +#include <string> +#include <vector> + +#include <base/callback.h> +#include <base/time/time.h> +#include <weave/enum_to_string.h> +#include <weave/settings.h> + +namespace weave { +namespace provider { + +class ConfigStore { + public: + virtual bool LoadDefaults(Settings* settings) = 0; + virtual std::string LoadSettings() = 0; + virtual void SaveSettings(const std::string& settings) = 0; + virtual void OnSettingsChanged(const Settings& settings) = 0; + + virtual std::string LoadBaseCommandDefs() = 0; + virtual std::map<std::string, std::string> LoadCommandDefs() = 0; + + virtual std::string LoadBaseStateDefs() = 0; + virtual std::string LoadBaseStateDefaults() = 0; + + virtual std::map<std::string, std::string> LoadStateDefs() = 0; + virtual std::vector<std::string> LoadStateDefaults() = 0; + + protected: + virtual ~ConfigStore() = default; +}; + +} // namespace provider +} // namespace weave + +#endif // LIBWEAVE_INCLUDE_WEAVE_PROVIDER_CONFIG_STORE_H_
diff --git a/libweave/include/weave/dns_service_discovery_provider.h b/libweave/include/weave/provider/dns_service_discovery.h similarity index 71% rename from libweave/include/weave/dns_service_discovery_provider.h rename to libweave/include/weave/provider/dns_service_discovery.h index bdba69d..dfd94eb 100644 --- a/libweave/include/weave/dns_service_discovery_provider.h +++ b/libweave/include/weave/provider/dns_service_discovery.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBWEAVE_INCLUDE_WEAVE_DNS_SERVICE_DISCOVERY_PROVIDER_H_ -#define LIBWEAVE_INCLUDE_WEAVE_DNS_SERVICE_DISCOVERY_PROVIDER_H_ +#ifndef LIBWEAVE_INCLUDE_WEAVE_PROVIDER_DNS_SERVICE_DISCOVERY_H_ +#define LIBWEAVE_INCLUDE_WEAVE_PROVIDER_DNS_SERVICE_DISCOVERY_H_ #include <string> #include <vector> @@ -11,8 +11,9 @@ #include <base/callback.h> namespace weave { +namespace provider { -class DnsServiceDiscoveryProvider { +class DnsServiceDiscovery { public: // Publishes new service using DNS-SD or updates existing one. virtual void PublishService(const std::string& service_type, @@ -27,9 +28,10 @@ virtual std::string GetId() const = 0; protected: - virtual ~DnsServiceDiscoveryProvider() = default; + virtual ~DnsServiceDiscovery() = default; }; +} // namespace provider } // namespace weave -#endif // LIBWEAVE_INCLUDE_WEAVE_DNS_SERVICE_DISCOVERY_PROVIDER_H_ +#endif // LIBWEAVE_INCLUDE_WEAVE_PROVIDER_DNS_SERVICE_DISCOVERY_H_
diff --git a/libweave/include/weave/http_client.h b/libweave/include/weave/provider/http_client.h similarity index 87% rename from libweave/include/weave/http_client.h rename to libweave/include/weave/provider/http_client.h index 6112271..9671f0d 100644 --- a/libweave/include/weave/http_client.h +++ b/libweave/include/weave/provider/http_client.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBWEAVE_INCLUDE_WEAVE_HTTP_CLIENT_H_ -#define LIBWEAVE_INCLUDE_WEAVE_HTTP_CLIENT_H_ +#ifndef LIBWEAVE_INCLUDE_WEAVE_PROVIDER_HTTP_CLIENT_H_ +#define LIBWEAVE_INCLUDE_WEAVE_PROVIDER_HTTP_CLIENT_H_ #include <string> #include <utility> @@ -13,6 +13,7 @@ #include <weave/error.h> namespace weave { +namespace provider { class HttpClient { public: @@ -49,6 +50,7 @@ virtual ~HttpClient() = default; }; +} // namespace provider } // namespace weave -#endif // LIBWEAVE_INCLUDE_WEAVE_HTTP_CLIENT_H_ +#endif // LIBWEAVE_INCLUDE_WEAVE_PROVIDER_HTTP_CLIENT_H_
diff --git a/libweave/include/weave/http_server.h b/libweave/include/weave/provider/http_server.h similarity index 88% rename from libweave/include/weave/http_server.h rename to libweave/include/weave/provider/http_server.h index 2716600..1d4ab1e 100644 --- a/libweave/include/weave/http_server.h +++ b/libweave/include/weave/provider/http_server.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBWEAVE_INCLUDE_WEAVE_HTTP_SERVER_H_ -#define LIBWEAVE_INCLUDE_WEAVE_HTTP_SERVER_H_ +#ifndef LIBWEAVE_INCLUDE_WEAVE_PROVIDER_HTTP_SERVER_H_ +#define LIBWEAVE_INCLUDE_WEAVE_PROVIDER_HTTP_SERVER_H_ #include <string> #include <vector> @@ -12,6 +12,7 @@ #include <weave/stream.h> namespace weave { +namespace provider { class HttpServer { public: @@ -53,6 +54,7 @@ virtual ~HttpServer() = default; }; +} // namespace provider } // namespace weave -#endif // LIBWEAVE_INCLUDE_WEAVE_HTTP_SERVER_H_ +#endif // LIBWEAVE_INCLUDE_WEAVE_PROVIDER_HTTP_SERVER_H_
diff --git a/libweave/include/weave/network_provider.h b/libweave/include/weave/provider/network.h similarity index 84% rename from libweave/include/weave/network_provider.h rename to libweave/include/weave/provider/network.h index ac1dcc8..bba60f0 100644 --- a/libweave/include/weave/network_provider.h +++ b/libweave/include/weave/provider/network.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBWEAVE_INCLUDE_WEAVE_NETWORK_PROVIDER_H_ -#define LIBWEAVE_INCLUDE_WEAVE_NETWORK_PROVIDER_H_ +#ifndef LIBWEAVE_INCLUDE_WEAVE_PROVIDER_NETWORK_H_ +#define LIBWEAVE_INCLUDE_WEAVE_PROVIDER_NETWORK_H_ #include <string> @@ -12,6 +12,7 @@ #include <weave/stream.h> namespace weave { +namespace provider { enum class NetworkState { kOffline = 0, @@ -22,7 +23,7 @@ // Interface with methods to detect network connectivity and opening network // connections. -class NetworkProvider { +class Network { public: // Callback type for AddConnectionChangedCallback. using ConnectionChangedCallback = base::Closure; @@ -48,9 +49,10 @@ const ErrorCallback& error_callback) = 0; protected: - virtual ~NetworkProvider() = default; + virtual ~Network() = default; }; +} // namespace provider } // namespace weave -#endif // LIBWEAVE_INCLUDE_WEAVE_NETWORK_PROVIDER_H_ +#endif // LIBWEAVE_INCLUDE_WEAVE_PROVIDER_NETWORK_H_
diff --git a/libweave/include/weave/task_runner.h b/libweave/include/weave/provider/task_runner.h similarity index 80% rename from libweave/include/weave/task_runner.h rename to libweave/include/weave/provider/task_runner.h index 43b81b7..daabc7e 100644 --- a/libweave/include/weave/task_runner.h +++ b/libweave/include/weave/provider/task_runner.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBWEAVE_INCLUDE_WEAVE_TASK_RUNNER_H_ -#define LIBWEAVE_INCLUDE_WEAVE_TASK_RUNNER_H_ +#ifndef LIBWEAVE_INCLUDE_WEAVE_PROVIDER_TASK_RUNNER_H_ +#define LIBWEAVE_INCLUDE_WEAVE_PROVIDER_TASK_RUNNER_H_ #include <string> #include <utility> @@ -14,6 +14,7 @@ #include <base/time/time.h> namespace weave { +namespace provider { // Interface with methods to post tasks into platform-specific message loop of // the current thread. @@ -30,6 +31,7 @@ virtual ~TaskRunner() = default; }; +} // namespace provider } // namespace weave -#endif // LIBWEAVE_INCLUDE_WEAVE_TASK_RUNNER_H_ +#endif // LIBWEAVE_INCLUDE_WEAVE_PROVIDER_TASK_RUNNER_H_
diff --git a/libweave/include/weave/test/mock_bluetooth.h b/libweave/include/weave/provider/test/mock_bluetooth.h similarity index 73% rename from libweave/include/weave/test/mock_bluetooth.h rename to libweave/include/weave/provider/test/mock_bluetooth.h index d02e314..d572fa4 100644 --- a/libweave/include/weave/test/mock_bluetooth.h +++ b/libweave/include/weave/provider/test/mock_bluetooth.h
@@ -14,12 +14,13 @@ * limitations under the License. */ -#ifndef LIBWEAVE_INCLUDE_WEAVE_TEST_MOCK_BLUETOOTH_H_ -#define LIBWEAVE_INCLUDE_WEAVE_TEST_MOCK_BLUETOOTH_H_ +#ifndef LIBWEAVE_INCLUDE_WEAVE_PROVIDER_TEST_MOCK_BLUETOOTH_H_ +#define LIBWEAVE_INCLUDE_WEAVE_PROVIDER_TEST_MOCK_BLUETOOTH_H_ -#include <weave/bluetooth.h> +#include <weave/provider/bluetooth.h> namespace weave { +namespace provider { namespace test { class MockBluetooth : public Bluetooth { @@ -27,6 +28,7 @@ }; } // namespace test +} // namespace provider } // namespace weave -#endif // LIBWEAVE_INCLUDE_WEAVE_TEST_MOCK_BLUETOOTH_H_ +#endif // LIBWEAVE_INCLUDE_WEAVE_PROVIDER_TEST_MOCK_BLUETOOTH_H_
diff --git a/libweave/include/weave/test/mock_config_store.h b/libweave/include/weave/provider/test/mock_config_store.h similarity index 81% rename from libweave/include/weave/test/mock_config_store.h rename to libweave/include/weave/provider/test/mock_config_store.h index 357db6e..7bc0db7 100644 --- a/libweave/include/weave/test/mock_config_store.h +++ b/libweave/include/weave/provider/test/mock_config_store.h
@@ -2,17 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBWEAVE_INCLUDE_WEAVE_TEST_MOCK_CONFIG_STORE_H_ -#define LIBWEAVE_INCLUDE_WEAVE_TEST_MOCK_CONFIG_STORE_H_ +#ifndef LIBWEAVE_INCLUDE_WEAVE_PROVIDER_TEST_MOCK_CONFIG_STORE_H_ +#define LIBWEAVE_INCLUDE_WEAVE_PROVIDER_TEST_MOCK_CONFIG_STORE_H_ #include <map> #include <string> #include <vector> #include <gmock/gmock.h> -#include <weave/config_store.h> +#include <weave/provider/config_store.h> namespace weave { +namespace provider { namespace test { class MockConfigStore : public ConfigStore { @@ -42,6 +43,7 @@ }; } // namespace test +} // namespace provider } // namespace weave -#endif // LIBWEAVE_INCLUDE_WEAVE_TEST_MOCK_CONFIG_STORE_H_ +#endif // LIBWEAVE_INCLUDE_WEAVE_PROVIDER_TEST_MOCK_CONFIG_STORE_H_
diff --git a/libweave/include/weave/provider/test/mock_dns_service_discovery.h b/libweave/include/weave/provider/test/mock_dns_service_discovery.h new file mode 100644 index 0000000..cfb070e --- /dev/null +++ b/libweave/include/weave/provider/test/mock_dns_service_discovery.h
@@ -0,0 +1,33 @@ +// Copyright 2015 The Chromium OS 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 LIBWEAVE_INCLUDE_WEAVE_PROVIDER_TEST_MOCK_DNS_SERVICE_DISCOVERY_H_ +#define LIBWEAVE_INCLUDE_WEAVE_PROVIDER_TEST_MOCK_DNS_SERVICE_DISCOVERY_H_ + +#include <weave/provider/dns_service_discovery.h> + +#include <string> +#include <vector> + +#include <gmock/gmock.h> + +namespace weave { +namespace provider { +namespace test { + +class MockDnsServiceDiscovery : public DnsServiceDiscovery { + public: + MOCK_METHOD3(PublishService, + void(const std::string&, + uint16_t, + const std::vector<std::string>&)); + MOCK_METHOD1(StopPublishing, void(const std::string&)); + MOCK_CONST_METHOD0(GetId, std::string()); +}; + +} // namespace test +} // namespace provider +} // namespace weave + +#endif // LIBWEAVE_INCLUDE_WEAVE_PROVIDER_TEST_MOCK_DNS_SERVICE_DISCOVERY_H_
diff --git a/libweave/include/weave/test/mock_http_client.h b/libweave/include/weave/provider/test/mock_http_client.h similarity index 84% rename from libweave/include/weave/test/mock_http_client.h rename to libweave/include/weave/provider/test/mock_http_client.h index f5c04ea..21af699 100644 --- a/libweave/include/weave/test/mock_http_client.h +++ b/libweave/include/weave/provider/test/mock_http_client.h
@@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBWEAVE_INCLUDE_WEAVE_TEST_MOCK_HTTP_CLIENT_H_ -#define LIBWEAVE_INCLUDE_WEAVE_TEST_MOCK_HTTP_CLIENT_H_ +#ifndef LIBWEAVE_INCLUDE_WEAVE_PROVIDER_TEST_MOCK_HTTP_CLIENT_H_ +#define LIBWEAVE_INCLUDE_WEAVE_PROVIDER_TEST_MOCK_HTTP_CLIENT_H_ -#include <weave/http_client.h> +#include <weave/provider/http_client.h> #include <memory> #include <string> @@ -13,6 +13,7 @@ #include <gmock/gmock.h> namespace weave { +namespace provider { namespace test { class MockHttpClientResponse : public HttpClient::Response { @@ -48,6 +49,7 @@ }; } // namespace test +} // namespace provider } // namespace weave -#endif // LIBWEAVE_INCLUDE_WEAVE_TEST_MOCK_HTTP_CLIENT_H_ +#endif // LIBWEAVE_INCLUDE_WEAVE_PROVIDER_TEST_MOCK_HTTP_CLIENT_H_
diff --git a/libweave/include/weave/test/mock_http_server.h b/libweave/include/weave/provider/test/mock_http_server.h similarity index 71% rename from libweave/include/weave/test/mock_http_server.h rename to libweave/include/weave/provider/test/mock_http_server.h index 9f8bbcc..3beb4ae 100644 --- a/libweave/include/weave/test/mock_http_server.h +++ b/libweave/include/weave/provider/test/mock_http_server.h
@@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBWEAVE_INCLUDE_WEAVE_TEST_MOCK_HTTP_SERVER_H_ -#define LIBWEAVE_INCLUDE_WEAVE_TEST_MOCK_HTTP_SERVER_H_ +#ifndef LIBWEAVE_INCLUDE_WEAVE_PROVIDER_TEST_MOCK_HTTP_SERVER_H_ +#define LIBWEAVE_INCLUDE_WEAVE_PROVIDER_TEST_MOCK_HTTP_SERVER_H_ -#include <weave/http_server.h> +#include <weave/provider/http_server.h> #include <string> #include <vector> @@ -13,6 +13,7 @@ #include <base/callback.h> namespace weave { +namespace provider { namespace test { class MockHttpServer : public HttpServer { @@ -27,6 +28,7 @@ }; } // namespace test +} // namespace provider } // namespace weave -#endif // LIBWEAVE_INCLUDE_WEAVE_TEST_MOCK_HTTP_SERVER_H_ +#endif // LIBWEAVE_INCLUDE_WEAVE_PROVIDER_TEST_MOCK_HTTP_SERVER_H_
diff --git a/libweave/include/weave/test/mock_network_provider.h b/libweave/include/weave/provider/test/mock_network.h similarity index 68% rename from libweave/include/weave/test/mock_network_provider.h rename to libweave/include/weave/provider/test/mock_network.h index c519f74..3da43be 100644 --- a/libweave/include/weave/test/mock_network_provider.h +++ b/libweave/include/weave/provider/test/mock_network.h
@@ -2,19 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBWEAVE_INCLUDE_WEAVE_TEST_MOCK_NETWORK_PROVIDER_H_ -#define LIBWEAVE_INCLUDE_WEAVE_TEST_MOCK_NETWORK_PROVIDER_H_ +#ifndef LIBWEAVE_INCLUDE_WEAVE_PROVIDER_TEST_MOCK_NETWORK_H_ +#define LIBWEAVE_INCLUDE_WEAVE_PROVIDER_TEST_MOCK_NETWORK_H_ -#include <weave/network_provider.h> +#include <weave/provider/network.h> #include <string> #include <gmock/gmock.h> namespace weave { +namespace provider { namespace test { -class MockNetworkProvider : public NetworkProvider { +class MockNetwork : public Network { public: MOCK_METHOD1(AddConnectionChangedCallback, void(const ConnectionChangedCallback&)); @@ -27,6 +28,7 @@ }; } // namespace test +} // namespace provider } // namespace weave -#endif // LIBWEAVE_INCLUDE_WEAVE_TEST_MOCK_NETWORK_PROVIDER_H_ +#endif // LIBWEAVE_INCLUDE_WEAVE_PROVIDER_TEST_MOCK_NETWORK_H_
diff --git a/libweave/include/weave/test/mock_task_runner.h b/libweave/include/weave/provider/test/mock_task_runner.h similarity index 82% rename from libweave/include/weave/test/mock_task_runner.h rename to libweave/include/weave/provider/test/mock_task_runner.h index 0aa3186..3c58614 100644 --- a/libweave/include/weave/test/mock_task_runner.h +++ b/libweave/include/weave/provider/test/mock_task_runner.h
@@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBWEAVE_INCLUDE_WEAVE_TEST_MOCK_TASK_RUNNER_H_ -#define LIBWEAVE_INCLUDE_WEAVE_TEST_MOCK_TASK_RUNNER_H_ +#ifndef LIBWEAVE_INCLUDE_WEAVE_PROVIDER_TEST_MOCK_TASK_RUNNER_H_ +#define LIBWEAVE_INCLUDE_WEAVE_PROVIDER_TEST_MOCK_TASK_RUNNER_H_ -#include <weave/task_runner.h> +#include <weave/provider/task_runner.h> #include <algorithm> #include <queue> @@ -16,6 +16,7 @@ #include <gmock/gmock.h> namespace weave { +namespace provider { namespace test { class MockTaskRunner : public TaskRunner { @@ -58,6 +59,7 @@ }; } // namespace test +} // namespace provider } // namespace weave -#endif // LIBWEAVE_INCLUDE_WEAVE_TEST_MOCK_TASK_RUNNER_H_ +#endif // LIBWEAVE_INCLUDE_WEAVE_PROVIDER_TEST_MOCK_TASK_RUNNER_H_
diff --git a/libweave/include/weave/test/mock_wifi_provider.h b/libweave/include/weave/provider/test/mock_wifi.h similarity index 66% rename from libweave/include/weave/test/mock_wifi_provider.h rename to libweave/include/weave/provider/test/mock_wifi.h index 408e0ad..6c53d9a 100644 --- a/libweave/include/weave/test/mock_wifi_provider.h +++ b/libweave/include/weave/provider/test/mock_wifi.h
@@ -2,19 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBWEAVE_INCLUDE_WEAVE_TEST_MOCK_WIFI_PROVIDER_H_ -#define LIBWEAVE_INCLUDE_WEAVE_TEST_MOCK_WIFI_PROVIDER_H_ +#ifndef LIBWEAVE_INCLUDE_WEAVE_PROVIDER_TEST_MOCK_WIFI_H_ +#define LIBWEAVE_INCLUDE_WEAVE_PROVIDER_TEST_MOCK_WIFI_H_ -#include <weave/network_provider.h> +#include <weave/provider/network.h> #include <string> #include <gmock/gmock.h> namespace weave { +namespace provider { namespace test { -class MockWifiProvider : public WifiProvider { +class MockWifi : public Wifi { public: MOCK_METHOD4(Connect, void(const std::string&, @@ -26,6 +27,7 @@ }; } // namespace test +} // namespace provider } // namespace weave -#endif // LIBWEAVE_INCLUDE_WEAVE_TEST_MOCK_WIFI_PROVIDER_H_ +#endif // LIBWEAVE_INCLUDE_WEAVE_PROVIDER_TEST_MOCK_WIFI_H_
diff --git a/libweave/include/weave/wifi_provider.h b/libweave/include/weave/provider/wifi.h similarity index 78% rename from libweave/include/weave/wifi_provider.h rename to libweave/include/weave/provider/wifi.h index 4173796..51f370c 100644 --- a/libweave/include/weave/wifi_provider.h +++ b/libweave/include/weave/provider/wifi.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBWEAVE_INCLUDE_WEAVE_WIFI_PROVIDER_H_ -#define LIBWEAVE_INCLUDE_WEAVE_WIFI_PROVIDER_H_ +#ifndef LIBWEAVE_INCLUDE_WEAVE_PROVIDER_WIFI_H_ +#define LIBWEAVE_INCLUDE_WEAVE_PROVIDER_WIFI_H_ #include <string> @@ -11,9 +11,10 @@ #include <weave/error.h> namespace weave { +namespace provider { // Interface with methods to control WiFi capability of the device. -class WifiProvider { +class Wifi { public: // Connects to the given network with the given pass-phrase. Implementation // should post either of callbacks. @@ -29,9 +30,10 @@ virtual void StopAccessPoint() = 0; protected: - virtual ~WifiProvider() = default; + virtual ~Wifi() = default; }; +} // namespace provider } // namespace weave -#endif // LIBWEAVE_INCLUDE_WEAVE_WIFI_PROVIDER_H_ +#endif // LIBWEAVE_INCLUDE_WEAVE_PROVIDER_WIFI_H_
diff --git a/libweave/include/weave/settings.h b/libweave/include/weave/settings.h new file mode 100644 index 0000000..fa32b86 --- /dev/null +++ b/libweave/include/weave/settings.h
@@ -0,0 +1,48 @@ +// Copyright 2015 The Chromium OS 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 LIBWEAVE_INCLUDE_WEAVE_SETTINGS_H_ +#define LIBWEAVE_INCLUDE_WEAVE_SETTINGS_H_ + +#include <set> +#include <string> + +#include <base/time/time.h> +#include <weave/privet.h> + +namespace weave { + +struct Settings { + std::string client_id; + std::string client_secret; + std::string api_key; + std::string oauth_url; + std::string service_url; + std::string name; + std::string description; + std::string location; + std::string local_anonymous_access_role; + bool local_discovery_enabled{true}; + bool local_pairing_enabled{true}; + std::string firmware_version; + std::string oem_name; + std::string model_name; + std::string model_id; + base::TimeDelta polling_period; + base::TimeDelta backup_polling_period; + + bool wifi_auto_setup_enabled{true}; + bool ble_setup_enabled{false}; + std::set<PairingType> pairing_modes; + std::string embedded_code; + + std::string device_id; + std::string refresh_token; + std::string robot_account; + std::string last_configured_ssid; +}; + +} // namespace weave + +#endif // LIBWEAVE_INCLUDE_WEAVE_SETTINGS_H_
diff --git a/libweave/include/weave/test/fake_stream.h b/libweave/include/weave/test/fake_stream.h index 3c21571..8abb491 100644 --- a/libweave/include/weave/test/fake_stream.h +++ b/libweave/include/weave/test/fake_stream.h
@@ -14,14 +14,16 @@ namespace weave { +namespace provider { class TaskRunner; +} namespace test { class FakeStream : public Stream { public: - explicit FakeStream(TaskRunner* task_runner); - FakeStream(TaskRunner* task_runner, const std::string& read_data); + explicit FakeStream(provider::TaskRunner* task_runner); + FakeStream(provider::TaskRunner* task_runner, const std::string& read_data); void ExpectWritePacketString(base::TimeDelta, const std::string& data); void AddReadPacketString(base::TimeDelta, const std::string& data); @@ -37,7 +39,7 @@ const ErrorCallback& error_callback) override; private: - TaskRunner* task_runner_{nullptr}; + provider::TaskRunner* task_runner_{nullptr}; std::string write_data_; std::string read_data_; };
diff --git a/libweave/include/weave/test/mock_dns_service_discovery_provider.h b/libweave/include/weave/test/mock_dns_service_discovery_provider.h deleted file mode 100644 index 6d187f8..0000000 --- a/libweave/include/weave/test/mock_dns_service_discovery_provider.h +++ /dev/null
@@ -1,31 +0,0 @@ -// Copyright 2015 The Chromium OS 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 LIBWEAVE_INCLUDE_WEAVE_TEST_MOCK_DNS_SERVICE_DISCOVERY_PROVIDER_H_ -#define LIBWEAVE_INCLUDE_WEAVE_TEST_MOCK_DNS_SERVICE_DISCOVERY_PROVIDER_H_ - -#include <weave/dns_service_discovery_provider.h> - -#include <string> -#include <vector> - -#include <gmock/gmock.h> - -namespace weave { -namespace test { - -class MockDnsServiceDiscovery : public DnsServiceDiscoveryProvider { - public: - MOCK_METHOD3(PublishService, - void(const std::string&, - uint16_t, - const std::vector<std::string>&)); - MOCK_METHOD1(StopPublishing, void(const std::string&)); - MOCK_CONST_METHOD0(GetId, std::string()); -}; - -} // namespace test -} // namespace weave - -#endif // LIBWEAVE_INCLUDE_WEAVE_TEST_MOCK_DNS_SERVICE_DISCOVERY_PROVIDER_H_
diff --git a/libweave/src/base_api_handler_unittest.cc b/libweave/src/base_api_handler_unittest.cc index 2e67822..52f9574 100644 --- a/libweave/src/base_api_handler_unittest.cc +++ b/libweave/src/base_api_handler_unittest.cc
@@ -7,8 +7,8 @@ #include <base/strings/string_number_conversions.h> #include <base/values.h> #include <gtest/gtest.h> -#include <weave/test/mock_config_store.h> -#include <weave/test/mock_http_client.h> +#include <weave/provider/test/mock_config_store.h> +#include <weave/provider/test/mock_http_client.h> #include "libweave/src/commands/command_manager.h" #include "libweave/src/commands/unittest_utils.h" @@ -65,8 +65,8 @@ std::unique_ptr<Config> config{new Config{&config_store_}}; config->Load(); dev_reg_.reset(new DeviceRegistrationInfo(command_manager_, state_manager_, - std::move(config), nullptr, - &http_client_, true, nullptr)); + true, std::move(config), nullptr, + &http_client_, nullptr)); handler_.reset( new BaseApiHandler{dev_reg_.get(), state_manager_, command_manager_}); } @@ -91,8 +91,8 @@ command_manager_->FindCommand(id)->GetStatus()); } - test::MockConfigStore config_store_; - StrictMock<test::MockHttpClient> http_client_; + provider::test::MockConfigStore config_store_; + StrictMock<provider::test::MockHttpClient> http_client_; std::unique_ptr<DeviceRegistrationInfo> dev_reg_; std::shared_ptr<CommandManager> command_manager_; testing::StrictMock<MockStateChangeQueueInterface> mock_state_change_queue_;
diff --git a/libweave/src/commands/cloud_command_proxy.cc b/libweave/src/commands/cloud_command_proxy.cc index d38fa04..23517b5 100644 --- a/libweave/src/commands/cloud_command_proxy.cc +++ b/libweave/src/commands/cloud_command_proxy.cc
@@ -6,7 +6,7 @@ #include <base/bind.h> #include <weave/enum_to_string.h> -#include <weave/task_runner.h> +#include <weave/provider/task_runner.h> #include "libweave/src/commands/command_instance.h" #include "libweave/src/commands/prop_constraints.h" @@ -20,7 +20,7 @@ CloudCommandUpdateInterface* cloud_command_updater, StateChangeQueueInterface* state_change_queue, std::unique_ptr<BackoffEntry> backoff_entry, - TaskRunner* task_runner) + provider::TaskRunner* task_runner) : command_instance_{command_instance}, cloud_command_updater_{cloud_command_updater}, state_change_queue_{state_change_queue},
diff --git a/libweave/src/commands/cloud_command_proxy.h b/libweave/src/commands/cloud_command_proxy.h index 2dcb697..5195294 100644 --- a/libweave/src/commands/cloud_command_proxy.h +++ b/libweave/src/commands/cloud_command_proxy.h
@@ -22,7 +22,10 @@ namespace weave { class CommandInstance; + +namespace provider { class TaskRunner; +} // Command proxy which publishes command updates to the cloud. class CloudCommandProxy final : public Command::Observer { @@ -31,7 +34,7 @@ CloudCommandUpdateInterface* cloud_command_updater, StateChangeQueueInterface* state_change_queue, std::unique_ptr<BackoffEntry> backoff_entry, - TaskRunner* task_runner); + provider::TaskRunner* task_runner); ~CloudCommandProxy() override = default; // CommandProxyInterface implementation/overloads. @@ -70,7 +73,7 @@ CommandInstance* command_instance_; CloudCommandUpdateInterface* cloud_command_updater_; StateChangeQueueInterface* state_change_queue_; - TaskRunner* task_runner_{nullptr}; + provider::TaskRunner* task_runner_{nullptr}; // Backoff for SendCommandUpdate() method. std::unique_ptr<BackoffEntry> cloud_backoff_entry_;
diff --git a/libweave/src/commands/cloud_command_proxy_unittest.cc b/libweave/src/commands/cloud_command_proxy_unittest.cc index fb881d1..3a3ce38 100644 --- a/libweave/src/commands/cloud_command_proxy_unittest.cc +++ b/libweave/src/commands/cloud_command_proxy_unittest.cc
@@ -9,7 +9,7 @@ #include <gmock/gmock.h> #include <gtest/gtest.h> -#include <weave/test/mock_task_runner.h> +#include <weave/provider/test/mock_task_runner.h> #include "libweave/src/commands/command_dictionary.h" #include "libweave/src/commands/command_instance.h" @@ -136,7 +136,7 @@ base::CallbackList<void(StateChangeQueueInterface::UpdateID)> callbacks_; testing::StrictMock<MockCloudCommandUpdateInterface> cloud_updater_; testing::StrictMock<MockStateChangeQueueInterface> state_change_queue_; - testing::StrictMock<test::MockTaskRunner> task_runner_; + testing::StrictMock<provider::test::MockTaskRunner> task_runner_; std::queue<base::Closure> task_queue_; CommandDictionary command_dictionary_; std::unique_ptr<CommandInstance> command_instance_;
diff --git a/libweave/src/commands/command_manager.cc b/libweave/src/commands/command_manager.cc index efad250..8a3237e 100644 --- a/libweave/src/commands/command_manager.cc +++ b/libweave/src/commands/command_manager.cc
@@ -5,9 +5,9 @@ #include "libweave/src/commands/command_manager.h" #include <base/values.h> -#include <weave/config_store.h> #include <weave/enum_to_string.h> #include <weave/error.h> +#include <weave/provider/config_store.h> #include "libweave/src/commands/schema_constants.h" #include "libweave/src/utils.h" @@ -59,7 +59,7 @@ return LoadCommands(*dict, category, error); } -void CommandManager::Startup(ConfigStore* config_store) { +void CommandManager::Startup(provider::ConfigStore* config_store) { LOG(INFO) << "Initializing CommandManager."; // Load global standard GCD command dictionary.
diff --git a/libweave/src/commands/command_manager.h b/libweave/src/commands/command_manager.h index e014fca..6db1ef4 100644 --- a/libweave/src/commands/command_manager.h +++ b/libweave/src/commands/command_manager.h
@@ -20,7 +20,10 @@ namespace weave { class CommandInstance; + +namespace provider { class ConfigStore; +} // CommandManager class that will have a list of all the device command // schemas as well as the live command queue of pending command instances @@ -78,7 +81,7 @@ // Initializes the object and loads: // 1) the standard GCD command dictionary // 2) static vendor-provided command definitions - void Startup(weave::ConfigStore* config_store); + void Startup(weave::provider::ConfigStore* config_store); // Adds a new command to the command queue. void AddCommand(std::unique_ptr<CommandInstance> command_instance);
diff --git a/libweave/src/commands/command_manager_unittest.cc b/libweave/src/commands/command_manager_unittest.cc index 2e7ce27..b97799d 100644 --- a/libweave/src/commands/command_manager_unittest.cc +++ b/libweave/src/commands/command_manager_unittest.cc
@@ -8,7 +8,7 @@ #include <base/json/json_writer.h> #include <gtest/gtest.h> -#include <weave/test/mock_config_store.h> +#include <weave/provider/test/mock_config_store.h> #include "libweave/src/bind_lambda.h" #include "libweave/src/commands/unittest_utils.h" @@ -115,7 +115,7 @@ TEST(CommandManager, ShouldLoadStandardAndTestDefinitions) { CommandManager manager; - test::MockConfigStore config_store; + provider::test::MockConfigStore config_store; EXPECT_CALL(config_store, LoadBaseCommandDefs()) .WillOnce(Return(kTestBaseCommands)); EXPECT_CALL(config_store, LoadCommandDefs())
diff --git a/libweave/src/config.cc b/libweave/src/config.cc index 5783486..55b0c7b 100644 --- a/libweave/src/config.cc +++ b/libweave/src/config.cc
@@ -70,10 +70,10 @@ } // namespace -Config::Config(ConfigStore* config_store) +Config::Config(provider::ConfigStore* config_store) : settings_{CreateDefaultSettings()}, config_store_{config_store} { if (config_store_) { - AddOnChangedCallback(base::Bind(&ConfigStore::OnSettingsChanged, + AddOnChangedCallback(base::Bind(&provider::ConfigStore::OnSettingsChanged, base::Unretained(config_store_))); } }
diff --git a/libweave/src/config.h b/libweave/src/config.h index 2da5d0b..c25ff6e 100644 --- a/libweave/src/config.h +++ b/libweave/src/config.h
@@ -10,8 +10,8 @@ #include <vector> #include <base/callback.h> -#include <weave/config_store.h> #include <weave/error.h> +#include <weave/provider/config_store.h> #include "libweave/src/privet/security_delegate.h" @@ -25,7 +25,7 @@ using OnChangedCallback = base::Callback<void(const Settings&)>; ~Config() = default; - explicit Config(ConfigStore* config_store); + explicit Config(provider::ConfigStore* config_store); void AddOnChangedCallback(const OnChangedCallback& callback); const Settings& GetSettings() const; @@ -93,7 +93,7 @@ void Save(); Settings settings_; - ConfigStore* config_store_{nullptr}; + provider::ConfigStore* config_store_{nullptr}; std::vector<OnChangedCallback> on_changed_; DISALLOW_COPY_AND_ASSIGN(Config);
diff --git a/libweave/src/config_unittest.cc b/libweave/src/config_unittest.cc index ec9b5a0..8968b50 100644 --- a/libweave/src/config_unittest.cc +++ b/libweave/src/config_unittest.cc
@@ -9,7 +9,7 @@ #include <base/bind.h> #include <gmock/gmock.h> #include <gtest/gtest.h> -#include <weave/test/mock_config_store.h> +#include <weave/provider/test/mock_config_store.h> #include "libweave/src/commands/unittest_utils.h" @@ -35,7 +35,7 @@ MOCK_METHOD1(OnConfigChanged, void(const Settings&)); - test::MockConfigStore config_store_; + provider::test::MockConfigStore config_store_; std::unique_ptr<Config> config_; const Config default_{nullptr}; };
diff --git a/libweave/src/device_manager.cc b/libweave/src/device_manager.cc index 4e8479e..f8c4ef6 100644 --- a/libweave/src/device_manager.cc +++ b/libweave/src/device_manager.cc
@@ -30,14 +30,14 @@ DeviceManager::~DeviceManager() {} void DeviceManager::Start(const Options& options, - ConfigStore* config_store, - TaskRunner* task_runner, - HttpClient* http_client, - NetworkProvider* network, - DnsServiceDiscoveryProvider* dns_sd, - HttpServer* http_server, - WifiProvider* wifi, - Bluetooth* bluetooth) { + provider::ConfigStore* config_store, + provider::TaskRunner* task_runner, + provider::HttpClient* http_client, + provider::Network* network, + provider::DnsServiceDiscovery* dns_sd, + provider::HttpServer* http_server, + provider::Wifi* wifi, + provider::Bluetooth* bluetooth) { command_manager_ = std::make_shared<CommandManager>(); command_manager_->Startup(config_store); state_change_queue_.reset(new StateChangeQueue(kMaxStateChangeQueueSize)); @@ -50,8 +50,8 @@ // TODO(avakulenko): Figure out security implications of storing // device info state data unencrypted. device_info_.reset(new DeviceRegistrationInfo( - command_manager_, state_manager_, std::move(config), task_runner, - http_client, options.xmpp_enabled, network)); + command_manager_, state_manager_, options.xmpp_enabled, std::move(config), + task_runner, http_client, network)); base_api_handler_.reset( new BaseApiHandler{device_info_.get(), state_manager_, command_manager_}); @@ -87,12 +87,12 @@ } void DeviceManager::StartPrivet(const Options& options, - TaskRunner* task_runner, - NetworkProvider* network, - DnsServiceDiscoveryProvider* dns_sd, - HttpServer* http_server, - WifiProvider* wifi, - Bluetooth* bluetooth) { + provider::TaskRunner* task_runner, + provider::Network* network, + provider::DnsServiceDiscovery* dns_sd, + provider::HttpServer* http_server, + provider::Wifi* wifi, + provider::Bluetooth* bluetooth) { privet_.reset(new privet::Manager{}); privet_->Start(options, task_runner, network, dns_sd, http_server, wifi, device_info_.get(), command_manager_.get(),
diff --git a/libweave/src/device_manager.h b/libweave/src/device_manager.h index 3441dde..9a603fd 100644 --- a/libweave/src/device_manager.h +++ b/libweave/src/device_manager.h
@@ -27,14 +27,14 @@ ~DeviceManager() override; void Start(const Options& options, - ConfigStore* config_store, - TaskRunner* task_runner, - HttpClient* http_client, - NetworkProvider* network, - DnsServiceDiscoveryProvider* dns_sd, - HttpServer* http_server, - WifiProvider* wifi, - Bluetooth* bluetooth) override; + provider::ConfigStore* config_store, + provider::TaskRunner* task_runner, + provider::HttpClient* http_client, + provider::Network* network, + provider::DnsServiceDiscovery* dns_sd, + provider::HttpServer* http_server, + provider::Wifi* wifi, + provider::Bluetooth* bluetooth) override; Commands* GetCommands() override; State* GetState() override; @@ -45,12 +45,12 @@ private: void StartPrivet(const Options& options, - TaskRunner* task_runner, - NetworkProvider* network, - DnsServiceDiscoveryProvider* dns_sd, - HttpServer* http_server, - WifiProvider* wifi, - Bluetooth* bluetooth); + provider::TaskRunner* task_runner, + provider::Network* network, + provider::DnsServiceDiscovery* dns_sd, + provider::HttpServer* http_server, + provider::Wifi* wifi, + provider::Bluetooth* bluetooth); void OnWiFiBootstrapStateChanged(weave::WifiSetupState state);
diff --git a/libweave/src/device_registration_info.cc b/libweave/src/device_registration_info.cc index 91f522a..66fe25f 100644 --- a/libweave/src/device_registration_info.cc +++ b/libweave/src/device_registration_info.cc
@@ -15,9 +15,9 @@ #include <base/json/json_writer.h> #include <base/strings/string_number_conversions.h> #include <base/values.h> -#include <weave/http_client.h> -#include <weave/network_provider.h> -#include <weave/task_runner.h> +#include <weave/provider/http_client.h> +#include <weave/provider/network.h> +#include <weave/provider/task_runner.h> #include "libweave/src/bind_lambda.h" #include "libweave/src/commands/cloud_command_proxy.h" @@ -40,6 +40,8 @@ namespace { +using provider::HttpClient; + inline void SetUnexpectedError(ErrorPtr* error) { Error::AddTo(error, FROM_HERE, kErrorDomainGCD, "unexpected_response", "Unexpected GCD error"); @@ -113,7 +115,8 @@ HttpClient* transport) : method_{method}, url_{url}, transport_{transport} {} - std::unique_ptr<HttpClient::Response> SendAndBlock(ErrorPtr* error) { + std::unique_ptr<provider::HttpClient::Response> SendAndBlock( + ErrorPtr* error) { return transport_->SendRequestAndBlock(method_, url_, GetFullHeaders(), data_, error); } @@ -213,11 +216,11 @@ DeviceRegistrationInfo::DeviceRegistrationInfo( const std::shared_ptr<CommandManager>& command_manager, const std::shared_ptr<StateManager>& state_manager, - std::unique_ptr<Config> config, - TaskRunner* task_runner, - HttpClient* http_client, bool notifications_enabled, - NetworkProvider* network) + std::unique_ptr<Config> config, + provider::TaskRunner* task_runner, + provider::HttpClient* http_client, + provider::Network* network) : http_client_{http_client}, task_runner_{task_runner}, command_manager_{command_manager},
diff --git a/libweave/src/device_registration_info.h b/libweave/src/device_registration_info.h index 8db6a88..9cc1a51 100644 --- a/libweave/src/device_registration_info.h +++ b/libweave/src/device_registration_info.h
@@ -17,7 +17,7 @@ #include <base/time/time.h> #include <weave/error.h> #include <weave/cloud.h> -#include <weave/http_client.h> +#include <weave/provider/http_client.h> #include "libweave/src/backoff_entry.h" #include "libweave/src/commands/cloud_command_update_interface.h" @@ -33,15 +33,14 @@ class DictionaryValue; } // namespace base -namespace chromeos { -class KeyValueStore; -} // namespace chromeos - namespace weave { -class NetworkProvider; class StateManager; + +namespace provider { +class Network; class TaskRunner; +} extern const char kErrorDomainOAuth2[]; extern const char kErrorDomainGCD[]; @@ -58,11 +57,11 @@ DeviceRegistrationInfo(const std::shared_ptr<CommandManager>& command_manager, const std::shared_ptr<StateManager>& state_manager, - std::unique_ptr<Config> config, - TaskRunner* task_runner, - HttpClient* http_client, bool notifications_enabled, - NetworkProvider* network); + std::unique_ptr<Config> config, + provider::TaskRunner* task_runner, + provider::HttpClient* http_client, + provider::Network* network); ~DeviceRegistrationInfo() override; @@ -162,7 +161,7 @@ const std::shared_ptr<base::Closure>& success_callback, const std::shared_ptr<CloudRequestErrorCallback>& error_callback, int id, - const HttpClient::Response& response); + const provider::HttpClient::Response& response); void OnRefreshAccessTokenError( const std::shared_ptr<base::Closure>& success_callback, const std::shared_ptr<CloudRequestErrorCallback>& error_callback, @@ -172,7 +171,7 @@ // Parse the OAuth response, and sets registration status to // kInvalidCredentials if our registration is no longer valid. std::unique_ptr<base::DictionaryValue> ParseOAuthResponse( - const HttpClient::Response& response, + const provider::HttpClient::Response& response, ErrorPtr* error); // This attempts to open a notification channel. The channel needs to be @@ -202,7 +201,7 @@ void OnCloudRequestSuccess( const std::shared_ptr<const CloudRequestData>& data, int request_id, - const HttpClient::Response& response); + const provider::HttpClient::Response& response); void OnCloudRequestError(const std::shared_ptr<const CloudRequestData>& data, int request_id, const Error* error); @@ -297,9 +296,9 @@ bool connected_to_cloud_{false}; // HTTP transport used for communications. - HttpClient* http_client_{nullptr}; + provider::HttpClient* http_client_{nullptr}; - TaskRunner* task_runner_{nullptr}; + provider::TaskRunner* task_runner_{nullptr}; // Global command manager. std::shared_ptr<CommandManager> command_manager_; // Device state manager. @@ -337,7 +336,7 @@ NotificationChannel* current_notification_channel_{nullptr}; bool notification_channel_starting_{false}; - NetworkProvider* network_{nullptr}; + provider::Network* network_{nullptr}; // Tracks our current registration status. RegistrationStatus registration_status_{RegistrationStatus::kUnconfigured};
diff --git a/libweave/src/device_registration_info_unittest.cc b/libweave/src/device_registration_info_unittest.cc index 8bbf987..f2fec8d 100644 --- a/libweave/src/device_registration_info_unittest.cc +++ b/libweave/src/device_registration_info_unittest.cc
@@ -8,8 +8,8 @@ #include <base/json/json_writer.h> #include <base/values.h> #include <gtest/gtest.h> -#include <weave/test/mock_config_store.h> -#include <weave/test/mock_http_client.h> +#include <weave/provider/test/mock_config_store.h> +#include <weave/provider/test/mock_http_client.h> #include "libweave/src/bind_lambda.h" #include "libweave/src/commands/command_manager.h" @@ -34,8 +34,9 @@ using test::CreateDictionaryValue; using test::CreateValue; -using test::MockHttpClient; -using test::MockHttpClientResponse; +using provider::test::MockHttpClient; +using provider::test::MockHttpClientResponse; +using provider::HttpClient; namespace { @@ -122,8 +123,8 @@ std::unique_ptr<Config> config{new Config{&config_store_}}; config_ = config.get(); dev_reg_.reset(new DeviceRegistrationInfo{command_manager_, state_manager_, - std::move(config), nullptr, - &http_client_, true, nullptr}); + true, std::move(config), nullptr, + &http_client_, nullptr}); ReloadDefaults(); } @@ -181,7 +182,7 @@ return dev_reg_->registration_status_; } - test::MockConfigStore config_store_; + provider::test::MockConfigStore config_store_; StrictMock<MockHttpClient> http_client_; base::DictionaryValue data_; Config* config_{nullptr};
diff --git a/libweave/src/notification/pull_channel.cc b/libweave/src/notification/pull_channel.cc index 2342e7d..78bfdcf 100644 --- a/libweave/src/notification/pull_channel.cc +++ b/libweave/src/notification/pull_channel.cc
@@ -6,13 +6,14 @@ #include <base/bind.h> #include <base/location.h> -#include <weave/task_runner.h> +#include <weave/provider/task_runner.h> #include "libweave/src/notification/notification_delegate.h" namespace weave { -PullChannel::PullChannel(base::TimeDelta pull_interval, TaskRunner* task_runner) +PullChannel::PullChannel(base::TimeDelta pull_interval, + provider::TaskRunner* task_runner) : pull_interval_{pull_interval}, task_runner_{task_runner} {} std::string PullChannel::GetName() const {
diff --git a/libweave/src/notification/pull_channel.h b/libweave/src/notification/pull_channel.h index 7f1b789..ef40403 100644 --- a/libweave/src/notification/pull_channel.h +++ b/libweave/src/notification/pull_channel.h
@@ -16,11 +16,13 @@ namespace weave { +namespace provider { class TaskRunner; +} // namespace class PullChannel : public NotificationChannel { public: - PullChannel(base::TimeDelta pull_interval, TaskRunner* task_runner); + PullChannel(base::TimeDelta pull_interval, provider::TaskRunner* task_runner); ~PullChannel() override = default; // Overrides from NotificationChannel. @@ -37,7 +39,7 @@ void RePost(); base::TimeDelta pull_interval_; - TaskRunner* task_runner_{nullptr}; + provider::TaskRunner* task_runner_{nullptr}; NotificationDelegate* delegate_{nullptr}; base::WeakPtrFactory<PullChannel> weak_ptr_factory_{this};
diff --git a/libweave/src/notification/xmpp_channel.cc b/libweave/src/notification/xmpp_channel.cc index 4734549..ca717c2 100644 --- a/libweave/src/notification/xmpp_channel.cc +++ b/libweave/src/notification/xmpp_channel.cc
@@ -7,8 +7,8 @@ #include <string> #include <base/bind.h> -#include <weave/network_provider.h> -#include <weave/task_runner.h> +#include <weave/provider/network.h> +#include <weave/provider/task_runner.h> #include "libweave/src/backoff_entry.h" #include "libweave/src/data_encoding.h" @@ -91,8 +91,8 @@ XmppChannel::XmppChannel(const std::string& account, const std::string& access_token, - TaskRunner* task_runner, - NetworkProvider* network) + provider::TaskRunner* task_runner, + provider::Network* network) : account_{account}, access_token_{access_token}, network_{network},
diff --git a/libweave/src/notification/xmpp_channel.h b/libweave/src/notification/xmpp_channel.h index 48ffd64..c6ab337 100644 --- a/libweave/src/notification/xmpp_channel.h +++ b/libweave/src/notification/xmpp_channel.h
@@ -22,8 +22,10 @@ namespace weave { -class NetworkProvider; +namespace provider { +class Network; class TaskRunner; +} // Simple interface to abstract XmppChannel's SendMessage() method. class XmppChannelInterface { @@ -43,8 +45,8 @@ // so you will need to reset the XmppClient every time this happens. XmppChannel(const std::string& account, const std::string& access_token, - TaskRunner* task_runner, - NetworkProvider* network); + provider::TaskRunner* task_runner, + provider::Network* network); ~XmppChannel() override = default; // Overrides from NotificationChannel. @@ -131,7 +133,7 @@ // OAuth access token for the account. Expires fairly frequently. std::string access_token_; - NetworkProvider* network_{nullptr}; + provider::Network* network_{nullptr}; std::unique_ptr<Stream> stream_; // Read buffer for incoming message packets. @@ -146,7 +148,7 @@ BackoffEntry backoff_entry_; NotificationDelegate* delegate_{nullptr}; - TaskRunner* task_runner_{nullptr}; + provider::TaskRunner* task_runner_{nullptr}; XmppStreamParser stream_parser_{this}; bool read_pending_{false}; bool write_pending_{false};
diff --git a/libweave/src/notification/xmpp_channel_unittest.cc b/libweave/src/notification/xmpp_channel_unittest.cc index a6992e9..beecd1d 100644 --- a/libweave/src/notification/xmpp_channel_unittest.cc +++ b/libweave/src/notification/xmpp_channel_unittest.cc
@@ -8,9 +8,9 @@ #include <queue> #include <gtest/gtest.h> +#include <weave/provider/test/mock_network.h> +#include <weave/provider/test/mock_task_runner.h> #include <weave/test/fake_stream.h> -#include <weave/test/mock_network_provider.h> -#include <weave/test/mock_task_runner.h> #include "libweave/src/bind_lambda.h" @@ -82,14 +82,13 @@ class FakeXmppChannel : public XmppChannel { public: - explicit FakeXmppChannel(TaskRunner* task_runner, - weave::NetworkProvider* network) + explicit FakeXmppChannel(provider::TaskRunner* task_runner, + provider::Network* network) : XmppChannel{kAccountName, kAccessToken, task_runner, network}, stream_{new test::FakeStream{task_runner_}}, fake_stream_{stream_.get()} {} - void Connect( - const base::Callback<void(std::unique_ptr<weave::Stream>)>& callback) { + void Connect(const base::Callback<void(std::unique_ptr<Stream>)>& callback) { callback.Run(std::move(stream_)); } @@ -111,9 +110,9 @@ test::FakeStream* fake_stream_{nullptr}; }; -class MockNetworkProvider : public weave::test::MockNetworkProvider { +class MockNetwork : public provider::test::MockNetwork { public: - MockNetworkProvider() { + MockNetwork() { EXPECT_CALL(*this, AddConnectionChangedCallback(_)) .WillRepeatedly(Return()); } @@ -145,8 +144,8 @@ EXPECT_EQ(st, xmpp_client_.state()); } - StrictMock<test::MockTaskRunner> task_runner_; - StrictMock<MockNetworkProvider> network_; + StrictMock<provider::test::MockTaskRunner> task_runner_; + StrictMock<MockNetwork> network_; FakeXmppChannel xmpp_client_{&task_runner_, &network_}; };
diff --git a/libweave/src/notification/xmpp_iq_stanza_handler.cc b/libweave/src/notification/xmpp_iq_stanza_handler.cc index 8803aae..0a0d87b 100644 --- a/libweave/src/notification/xmpp_iq_stanza_handler.cc +++ b/libweave/src/notification/xmpp_iq_stanza_handler.cc
@@ -7,7 +7,7 @@ #include <base/bind.h> #include <base/strings/string_number_conversions.h> #include <base/strings/stringprintf.h> -#include <weave/task_runner.h> +#include <weave/provider/task_runner.h> #include "libweave/src/notification/xml_node.h" #include "libweave/src/notification/xmpp_channel.h" @@ -48,7 +48,7 @@ } // anonymous namespace IqStanzaHandler::IqStanzaHandler(XmppChannelInterface* xmpp_channel, - TaskRunner* task_runner) + provider::TaskRunner* task_runner) : xmpp_channel_{xmpp_channel}, task_runner_{task_runner} {} void IqStanzaHandler::SendRequest(const std::string& type,
diff --git a/libweave/src/notification/xmpp_iq_stanza_handler.h b/libweave/src/notification/xmpp_iq_stanza_handler.h index b4edcac..1de633f 100644 --- a/libweave/src/notification/xmpp_iq_stanza_handler.h +++ b/libweave/src/notification/xmpp_iq_stanza_handler.h
@@ -18,15 +18,19 @@ namespace weave { -class TaskRunner; class XmppChannelInterface; +namespace provider { +class TaskRunner; +} + class IqStanzaHandler { public: using ResponseCallback = base::Callback<void(std::unique_ptr<XmlNode>)>; using TimeoutCallback = base::Closure; - IqStanzaHandler(XmppChannelInterface* xmpp_channel, TaskRunner* task_runner); + IqStanzaHandler(XmppChannelInterface* xmpp_channel, + provider::TaskRunner* task_runner); // Sends <iq> request to the server. // |type| is the IQ stanza type, one of "get", "set", "query". @@ -66,7 +70,7 @@ void OnTimeOut(RequestId id, const TimeoutCallback& timeout_callback); XmppChannelInterface* xmpp_channel_; - TaskRunner* task_runner_{nullptr}; + provider::TaskRunner* task_runner_{nullptr}; std::map<RequestId, ResponseCallback> requests_; RequestId last_request_id_{0};
diff --git a/libweave/src/notification/xmpp_iq_stanza_handler_unittest.cc b/libweave/src/notification/xmpp_iq_stanza_handler_unittest.cc index 3880f34..27392b3 100644 --- a/libweave/src/notification/xmpp_iq_stanza_handler_unittest.cc +++ b/libweave/src/notification/xmpp_iq_stanza_handler_unittest.cc
@@ -9,7 +9,7 @@ #include <gmock/gmock.h> #include <gtest/gtest.h> -#include <weave/test/mock_task_runner.h> +#include <weave/provider/test/mock_task_runner.h> #include "libweave/src/bind_lambda.h" #include "libweave/src/notification/xml_node.h" @@ -76,7 +76,7 @@ class IqStanzaHandlerTest : public testing::Test { public: testing::StrictMock<MockXmppChannelInterface> mock_xmpp_channel_; - test::MockTaskRunner task_runner_; + provider::test::MockTaskRunner task_runner_; IqStanzaHandler iq_stanza_handler_{&mock_xmpp_channel_, &task_runner_}; MockResponseReceiver receiver_; };
diff --git a/libweave/src/privet/cloud_delegate.cc b/libweave/src/privet/cloud_delegate.cc index 03e74c7..7d4a5f0 100644 --- a/libweave/src/privet/cloud_delegate.cc +++ b/libweave/src/privet/cloud_delegate.cc
@@ -12,7 +12,7 @@ #include <base/memory/weak_ptr.h> #include <base/values.h> #include <weave/error.h> -#include <weave/task_runner.h> +#include <weave/provider/task_runner.h> #include "libweave/src/backoff_entry.h" #include "libweave/src/commands/command_manager.h" @@ -39,7 +39,7 @@ class CloudDelegateImpl : public CloudDelegate { public: - CloudDelegateImpl(TaskRunner* task_runner, + CloudDelegateImpl(provider::TaskRunner* task_runner, DeviceRegistrationInfo* device, CommandManager* command_manager, StateManager* state_manager) @@ -340,7 +340,7 @@ return false; } - TaskRunner* task_runner_{nullptr}; + provider::TaskRunner* task_runner_{nullptr}; DeviceRegistrationInfo* device_{nullptr}; CommandManager* command_manager_{nullptr}; StateManager* state_manager_{nullptr}; @@ -378,7 +378,7 @@ // static std::unique_ptr<CloudDelegate> CloudDelegate::CreateDefault( - TaskRunner* task_runner, + provider::TaskRunner* task_runner, DeviceRegistrationInfo* device, CommandManager* command_manager, StateManager* state_manager) {
diff --git a/libweave/src/privet/cloud_delegate.h b/libweave/src/privet/cloud_delegate.h index 0b72a44..8152f78 100644 --- a/libweave/src/privet/cloud_delegate.h +++ b/libweave/src/privet/cloud_delegate.h
@@ -25,7 +25,10 @@ class CommandManager; class DeviceRegistrationInfo; class StateManager; + +namespace provider { class TaskRunner; +} namespace privet { @@ -134,7 +137,7 @@ // Create default instance. static std::unique_ptr<CloudDelegate> CreateDefault( - TaskRunner* task_runner, + provider::TaskRunner* task_runner, DeviceRegistrationInfo* device, CommandManager* command_manager, StateManager* state_manager);
diff --git a/libweave/src/privet/privet_manager.cc b/libweave/src/privet/privet_manager.cc index cf25773..52a2657 100644 --- a/libweave/src/privet/privet_manager.cc +++ b/libweave/src/privet/privet_manager.cc
@@ -15,7 +15,7 @@ #include <base/scoped_observer.h> #include <base/strings/string_number_conversions.h> #include <base/values.h> -#include <weave/network_provider.h> +#include <weave/provider/network.h> #include "libweave/src/device_registration_info.h" #include "libweave/src/http_constants.h" @@ -29,16 +29,22 @@ namespace weave { namespace privet { +using provider::TaskRunner; +using provider::Network; +using provider::DnsServiceDiscovery; +using provider::HttpServer; +using provider::Wifi; + Manager::Manager() {} Manager::~Manager() {} void Manager::Start(const Device::Options& options, TaskRunner* task_runner, - NetworkProvider* network, - DnsServiceDiscoveryProvider* dns_sd, + Network* network, + DnsServiceDiscovery* dns_sd, HttpServer* http_server, - WifiProvider* wifi, + Wifi* wifi, DeviceRegistrationInfo* device, CommandManager* command_manager, StateManager* state_manager) {
diff --git a/libweave/src/privet/privet_manager.h b/libweave/src/privet/privet_manager.h index 7fc90a2..1c635da 100644 --- a/libweave/src/privet/privet_manager.h +++ b/libweave/src/privet/privet_manager.h
@@ -29,8 +29,8 @@ class CommandManager; class DeviceRegistrationInfo; -class DnsServiceDiscoveryProvider; -class NetworkProvider; +class DnsServiceDiscovery; +class Network; class StateManager; namespace privet { @@ -48,11 +48,11 @@ ~Manager() override; void Start(const weave::Device::Options& options, - TaskRunner* task_runner, - NetworkProvider* network, - DnsServiceDiscoveryProvider* dns_sd, - HttpServer* http_server, - WifiProvider* wifi, + provider::TaskRunner* task_runner, + provider::Network* network, + provider::DnsServiceDiscovery* dns_sd, + provider::HttpServer* http_server, + provider::Wifi* wifi, DeviceRegistrationInfo* device, CommandManager* command_manager, StateManager* state_manager); @@ -70,20 +70,22 @@ // CloudDelegate::Observer void OnDeviceInfoChanged() override; - void PrivetRequestHandler(const HttpServer::Request& request, - const HttpServer::OnReplyCallback& callback); + void PrivetRequestHandler( + const provider::HttpServer::Request& request, + const provider::HttpServer::OnReplyCallback& callback); - void PrivetResponseHandler(const HttpServer::OnReplyCallback& callback, - int status, - const base::DictionaryValue& output); + void PrivetResponseHandler( + const provider::HttpServer::OnReplyCallback& callback, + int status, + const base::DictionaryValue& output); - void HelloWorldHandler(const HttpServer::Request& request, - const HttpServer::OnReplyCallback& callback); + void HelloWorldHandler(const provider::HttpServer::Request& request, + const provider::HttpServer::OnReplyCallback& callback); void OnChanged(); void OnConnectivityChanged(); - void OnHttpServerStatusChanged(const HttpServer& server); + void OnHttpServerStatusChanged(const provider::HttpServer& server); bool disable_security_{false}; std::unique_ptr<CloudDelegate> cloud_;
diff --git a/libweave/src/privet/privet_types.cc b/libweave/src/privet/privet_types.cc index 9c32bad..aebf63b 100644 --- a/libweave/src/privet/privet_types.cc +++ b/libweave/src/privet/privet_types.cc
@@ -8,8 +8,8 @@ #include <weave/enum_to_string.h> #include <weave/export.h> -#include <weave/network_provider.h> #include <weave/privet.h> +#include <weave/provider/network.h> namespace weave { @@ -20,6 +20,7 @@ using privet::CryptoType; using privet::SetupState; using privet::WifiType; +using provider::NetworkState; const EnumToStringMap<PairingType>::Map kPairingTypeMap[] = { {PairingType::kPinCode, "pinCode"}, @@ -67,7 +68,7 @@ {WifiSetupState::kConnecting, "connecting"}, }; -const EnumToStringMap<NetworkState>::Map kNetworkStateMap[] = { +const EnumToStringMap<provider::NetworkState>::Map kNetworkStateMap[] = { {NetworkState::kOffline, "offline"}, {NetworkState::kFailure, "failure"}, {NetworkState::kConnecting, "connecting"},
diff --git a/libweave/src/privet/publisher.cc b/libweave/src/privet/publisher.cc index 6a5b8bb..5d6567b 100644 --- a/libweave/src/privet/publisher.cc +++ b/libweave/src/privet/publisher.cc
@@ -6,8 +6,8 @@ #include <map> -#include <weave/dns_service_discovery_provider.h> #include <weave/error.h> +#include <weave/provider/dns_service_discovery.h> #include "libweave/src/privet/cloud_delegate.h" #include "libweave/src/privet/device_delegate.h" @@ -28,7 +28,7 @@ Publisher::Publisher(const DeviceDelegate* device, const CloudDelegate* cloud, const WifiDelegate* wifi, - DnsServiceDiscoveryProvider* dns_sd) + provider::DnsServiceDiscovery* dns_sd) : dns_sd_{dns_sd}, device_{device}, cloud_{cloud}, wifi_{wifi} { CHECK(device_); CHECK(cloud_);
diff --git a/libweave/src/privet/publisher.h b/libweave/src/privet/publisher.h index b73ea2e..d330992 100644 --- a/libweave/src/privet/publisher.h +++ b/libweave/src/privet/publisher.h
@@ -14,7 +14,9 @@ namespace weave { -class DnsServiceDiscoveryProvider; +namespace provider { +class DnsServiceDiscovery; +} namespace privet { @@ -28,7 +30,7 @@ Publisher(const DeviceDelegate* device, const CloudDelegate* cloud, const WifiDelegate* wifi, - DnsServiceDiscoveryProvider* dns_sd); + provider::DnsServiceDiscovery* dns_sd); ~Publisher() override; // IdentityDelegate implementation. @@ -42,7 +44,7 @@ void RemoveService(); bool is_publishing_{false}; - DnsServiceDiscoveryProvider* dns_sd_{nullptr}; + provider::DnsServiceDiscovery* dns_sd_{nullptr}; const DeviceDelegate* device_{nullptr}; const CloudDelegate* cloud_{nullptr};
diff --git a/libweave/src/privet/security_manager.cc b/libweave/src/privet/security_manager.cc index 588cbd3..1dfbab5 100644 --- a/libweave/src/privet/security_manager.cc +++ b/libweave/src/privet/security_manager.cc
@@ -16,7 +16,7 @@ #include <base/strings/string_number_conversions.h> #include <base/strings/stringprintf.h> #include <base/time/time.h> -#include <weave/task_runner.h> +#include <weave/provider/task_runner.h> #include "libweave/external/crypto/p224_spake.h" #include "libweave/src/data_encoding.h" @@ -121,7 +121,7 @@ SecurityManager::SecurityManager(const std::set<PairingType>& pairing_modes, const std::string& embedded_code, bool disable_security, - TaskRunner* task_runner) + provider::TaskRunner* task_runner) : is_security_disabled_(disable_security), pairing_modes_(pairing_modes), embedded_code_(embedded_code),
diff --git a/libweave/src/privet/security_manager.h b/libweave/src/privet/security_manager.h index 07f8c0c..8acbd1d 100644 --- a/libweave/src/privet/security_manager.h +++ b/libweave/src/privet/security_manager.h
@@ -24,7 +24,9 @@ namespace weave { +namespace provider { class TaskRunner; +} namespace privet { @@ -50,7 +52,7 @@ SecurityManager(const std::set<PairingType>& pairing_modes, const std::string& embedded_code, bool disable_security, - TaskRunner* task_runner); + provider::TaskRunner* task_runner); ~SecurityManager() override; // SecurityDelegate methods @@ -94,7 +96,7 @@ std::set<PairingType> pairing_modes_; std::string embedded_code_; // TODO(vitalybuka): Session cleanup can be done without posting tasks. - TaskRunner* task_runner_{nullptr}; + provider::TaskRunner* task_runner_{nullptr}; std::map<std::string, std::unique_ptr<KeyExchanger>> pending_sessions_; std::map<std::string, std::unique_ptr<KeyExchanger>> confirmed_sessions_; mutable int pairing_attemts_{0};
diff --git a/libweave/src/privet/security_manager_unittest.cc b/libweave/src/privet/security_manager_unittest.cc index b19b0ee..5c9fc2d 100644 --- a/libweave/src/privet/security_manager_unittest.cc +++ b/libweave/src/privet/security_manager_unittest.cc
@@ -19,7 +19,7 @@ #include <base/strings/string_util.h> #include <gmock/gmock.h> #include <gtest/gtest.h> -#include <weave/test/mock_task_runner.h> +#include <weave/provider/test/mock_task_runner.h> #include "libweave/external/crypto/p224_spake.h" #include "libweave/src/data_encoding.h" @@ -100,7 +100,7 @@ } const base::Time time_ = base::Time::FromTimeT(1410000000); - test::MockTaskRunner task_runner_; + provider::test::MockTaskRunner task_runner_; SecurityManager security_{{PairingType::kEmbeddedCode}, "1234", false,
diff --git a/libweave/src/privet/wifi_bootstrap_manager.cc b/libweave/src/privet/wifi_bootstrap_manager.cc index dff6c9f..4756a66 100644 --- a/libweave/src/privet/wifi_bootstrap_manager.cc +++ b/libweave/src/privet/wifi_bootstrap_manager.cc
@@ -7,9 +7,9 @@ #include <base/logging.h> #include <base/memory/weak_ptr.h> #include <weave/enum_to_string.h> -#include <weave/network_provider.h> -#include <weave/task_runner.h> -#include <weave/wifi_provider.h> +#include <weave/provider/network.h> +#include <weave/provider/task_runner.h> +#include <weave/provider/wifi.h> #include "libweave/src/bind_lambda.h" #include "libweave/src/privet/constants.h" @@ -17,13 +17,15 @@ namespace weave { namespace privet { +using provider::NetworkState; + WifiBootstrapManager::WifiBootstrapManager( const std::string& last_configured_ssid, const std::string& test_privet_ssid, bool ble_setup_enabled, - TaskRunner* task_runner, - NetworkProvider* network, - WifiProvider* wifi, + provider::TaskRunner* task_runner, + provider::Network* network, + provider::Wifi* wifi, CloudDelegate* gcd) : task_runner_{task_runner}, network_{network},
diff --git a/libweave/src/privet/wifi_bootstrap_manager.h b/libweave/src/privet/wifi_bootstrap_manager.h index fbf6360..8174cac 100644 --- a/libweave/src/privet/wifi_bootstrap_manager.h +++ b/libweave/src/privet/wifi_bootstrap_manager.h
@@ -22,9 +22,11 @@ namespace weave { -class NetworkProvider; +namespace provider { +class Network; class TaskRunner; -class WifiProvider; +class Wifi; +} namespace privet { @@ -40,9 +42,9 @@ WifiBootstrapManager(const std::string& last_configured_ssid, const std::string& test_privet_ssid, bool wifi_setup_enabled, - TaskRunner* task_runner, - NetworkProvider* shill_client, - WifiProvider* wifi, + provider::TaskRunner* task_runner, + provider::Network* shill_client, + provider::Wifi* wifi, CloudDelegate* gcd); ~WifiBootstrapManager() override = default; virtual void Init(); @@ -96,9 +98,9 @@ // It is not persisted to disk. SetupState setup_state_{SetupState::kNone}; ConnectionState connection_state_{ConnectionState::kDisabled}; - TaskRunner* task_runner_{nullptr}; - NetworkProvider* network_{nullptr}; - WifiProvider* wifi_{nullptr}; + provider::TaskRunner* task_runner_{nullptr}; + provider::Network* network_{nullptr}; + provider::Wifi* wifi_{nullptr}; WifiSsidGenerator ssid_generator_; base::Time monitor_until_;
diff --git a/libweave/src/states/state_manager.cc b/libweave/src/states/state_manager.cc index c277ab4..64a7db9 100644 --- a/libweave/src/states/state_manager.cc +++ b/libweave/src/states/state_manager.cc
@@ -6,7 +6,7 @@ #include <base/logging.h> #include <base/values.h> -#include <weave/config_store.h> +#include <weave/provider/config_store.h> #include "libweave/src/json_error_codes.h" #include "libweave/src/states/error_codes.h" @@ -28,7 +28,7 @@ callback.Run(); // Force to read current state. } -void StateManager::Startup(ConfigStore* config_store) { +void StateManager::Startup(provider::ConfigStore* config_store) { LOG(INFO) << "Initializing StateManager."; // Load standard device state definition.
diff --git a/libweave/src/states/state_manager.h b/libweave/src/states/state_manager.h index 59c7716..8f6b237 100644 --- a/libweave/src/states/state_manager.h +++ b/libweave/src/states/state_manager.h
@@ -27,7 +27,9 @@ namespace weave { +namespace provider { class ConfigStore; +} // StateManager is the class that aggregates the device state fragments // provided by device daemons and makes the aggregate device state available @@ -45,7 +47,7 @@ // Initializes the state manager and load device state fragments. // Called by Buffet daemon at startup. - void Startup(ConfigStore* config_store); + void Startup(provider::ConfigStore* config_store); // Returns all the categories the state properties are registered from. // As with GCD command handling, the category normally represent a device
diff --git a/libweave/src/states/state_manager_unittest.cc b/libweave/src/states/state_manager_unittest.cc index a7511cc..1ae60d7 100644 --- a/libweave/src/states/state_manager_unittest.cc +++ b/libweave/src/states/state_manager_unittest.cc
@@ -11,7 +11,7 @@ #include <base/values.h> #include <gmock/gmock.h> #include <gtest/gtest.h> -#include <weave/test/mock_config_store.h> +#include <weave/provider/test/mock_config_store.h> #include "libweave/src/commands/schema_constants.h" #include "libweave/src/commands/unittest_utils.h" @@ -138,7 +138,7 @@ } TEST_F(StateManagerTest, Startup) { - test::MockConfigStore config_store; + provider::test::MockConfigStore config_store; StateManager manager(&mock_state_change_queue_); EXPECT_CALL(config_store, LoadBaseStateDefs())
diff --git a/libweave/src/test/fake_stream.cc b/libweave/src/test/fake_stream.cc index 5adf462..786aa01 100644 --- a/libweave/src/test/fake_stream.cc +++ b/libweave/src/test/fake_stream.cc
@@ -6,13 +6,15 @@ #include <base/bind.h> #include <gtest/gtest.h> -#include <weave/task_runner.h> +#include <weave/provider/task_runner.h> namespace weave { namespace test { -FakeStream::FakeStream(TaskRunner* task_runner) : task_runner_{task_runner} {} -FakeStream::FakeStream(TaskRunner* task_runner, const std::string& read_data) +FakeStream::FakeStream(provider::TaskRunner* task_runner) + : task_runner_{task_runner} {} +FakeStream::FakeStream(provider::TaskRunner* task_runner, + const std::string& read_data) : task_runner_{task_runner}, read_data_{read_data} {} void FakeStream::CancelPendingOperations() {}
diff --git a/libweave/src/test/mock_http_client.cc b/libweave/src/test/mock_http_client.cc index 879f213..b17645c 100644 --- a/libweave/src/test/mock_http_client.cc +++ b/libweave/src/test/mock_http_client.cc
@@ -2,12 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <weave/test/mock_http_client.h> +#include <weave/provider/test/mock_http_client.h> #include <memory> #include <string> namespace weave { +namespace provider { namespace test { std::unique_ptr<HttpClient::Response> MockHttpClient::SendRequestAndBlock( @@ -38,4 +39,5 @@ } } // namespace test +} // namespace provider } // namespace weave
diff --git a/libweave/src/test/mock_task_runner.cc b/libweave/src/test/mock_task_runner.cc index a78b4e1..78af5ad 100644 --- a/libweave/src/test/mock_task_runner.cc +++ b/libweave/src/test/mock_task_runner.cc
@@ -2,13 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <weave/test/mock_task_runner.h> +#include <weave/provider/test/mock_task_runner.h> using testing::_; using testing::Invoke; using testing::AnyNumber; namespace weave { +namespace provider { namespace test { class MockTaskRunner::TestClock : public base::Clock { @@ -60,4 +61,5 @@ } } // namespace test +} // namespace provider } // namespace weave
diff --git a/libweave/src/weave_unittest.cc b/libweave/src/weave_unittest.cc index f5d7818..e92c266 100644 --- a/libweave/src/weave_unittest.cc +++ b/libweave/src/weave_unittest.cc
@@ -6,14 +6,14 @@ #include <gmock/gmock.h> #include <gtest/gtest.h> -#include <weave/test/mock_bluetooth.h> -#include <weave/test/mock_config_store.h> -#include <weave/test/mock_dns_service_discovery_provider.h> -#include <weave/test/mock_http_client.h> -#include <weave/test/mock_http_server.h> -#include <weave/test/mock_network_provider.h> -#include <weave/test/mock_task_runner.h> -#include <weave/test/mock_wifi_provider.h> +#include <weave/provider/test/mock_bluetooth.h> +#include <weave/provider/test/mock_config_store.h> +#include <weave/provider/test/mock_dns_service_discovery.h> +#include <weave/provider/test/mock_http_client.h> +#include <weave/provider/test/mock_http_server.h> +#include <weave/provider/test/mock_network.h> +#include <weave/provider/test/mock_task_runner.h> +#include <weave/provider/test/mock_wifi.h> #include <weave/test/unittest_utils.h> #include "libweave/src/bind_lambda.h" @@ -36,6 +36,8 @@ using test::CreateDictionaryValue; using test::ValueToString; +using provider::test::MockHttpClientResponse; +using provider::NetworkState; const char kCategory[] = "powerd"; @@ -172,8 +174,8 @@ const std::string& json_response) { EXPECT_CALL(http_client_, MockSendRequest(method, url, _, _, _)) .WillOnce(InvokeWithoutArgs([json_response]() { - test::MockHttpClientResponse* response = - new StrictMock<test::MockHttpClientResponse>; + provider::test::MockHttpClientResponse* response = + new StrictMock<provider::test::MockHttpClientResponse>; EXPECT_CALL(*response, GetStatusCode()) .Times(AtLeast(1)) .WillRepeatedly(Return(200)); @@ -224,7 +226,7 @@ void InitNetwork() { EXPECT_CALL(network_, AddConnectionChangedCallback(_)) .WillRepeatedly(Invoke( - [this](const NetworkProvider::ConnectionChangedCallback& cb) { + [this](const provider::Network::ConnectionChangedCallback& cb) { network_callbacks_.push_back(cb); })); EXPECT_CALL(network_, GetConnectionState()) @@ -264,13 +266,14 @@ EXPECT_CALL(http_server_, GetHttpsCertificateFingerprint()) .WillRepeatedly(ReturnRefOfCopy(std::vector<uint8_t>{1, 2, 3})); EXPECT_CALL(http_server_, AddRequestHandler(_, _)) - .WillRepeatedly(Invoke([this](const std::string& path_prefix, - const HttpServer::OnRequestCallback& cb) { - http_server_request_cb_.push_back(cb); - })); - EXPECT_CALL(http_server_, AddOnStateChangedCallback(_)) .WillRepeatedly( - Invoke([this](const HttpServer::OnStateChangedCallback& cb) { + Invoke([this](const std::string& path_prefix, + const provider::HttpServer::OnRequestCallback& cb) { + http_server_request_cb_.push_back(cb); + })); + EXPECT_CALL(http_server_, AddOnStateChangedCallback(_)) + .WillRepeatedly(Invoke( + [this](const provider::HttpServer::OnStateChangedCallback& cb) { http_server_changed_cb_.push_back(cb); })); } @@ -307,26 +310,28 @@ task_runner_.Run(); } - void NotifyNetworkChanged(NetworkState state, base::TimeDelta delay) { + void NotifyNetworkChanged(provider::NetworkState state, + base::TimeDelta delay) { EXPECT_CALL(network_, GetConnectionState()).WillRepeatedly(Return(state)); for (const auto& cb : network_callbacks_) { task_runner_.PostDelayedTask(FROM_HERE, cb, delay); } } - std::vector<HttpServer::OnStateChangedCallback> http_server_changed_cb_; - std::vector<HttpServer::OnRequestCallback> http_server_request_cb_; + std::vector<provider::HttpServer::OnStateChangedCallback> + http_server_changed_cb_; + std::vector<provider::HttpServer::OnRequestCallback> http_server_request_cb_; - StrictMock<test::MockConfigStore> config_store_; - StrictMock<test::MockTaskRunner> task_runner_; - StrictMock<test::MockHttpClient> http_client_; - StrictMock<test::MockNetworkProvider> network_; - StrictMock<test::MockDnsServiceDiscovery> dns_sd_; - StrictMock<test::MockHttpServer> http_server_; - StrictMock<test::MockWifiProvider> wifi_; - StrictMock<test::MockBluetooth> bluetooth_; + StrictMock<provider::test::MockConfigStore> config_store_; + StrictMock<provider::test::MockTaskRunner> task_runner_; + StrictMock<provider::test::MockHttpClient> http_client_; + StrictMock<provider::test::MockNetwork> network_; + StrictMock<provider::test::MockDnsServiceDiscovery> dns_sd_; + StrictMock<provider::test::MockHttpServer> http_server_; + StrictMock<provider::test::MockWifi> wifi_; + StrictMock<provider::test::MockBluetooth> bluetooth_; - std::vector<NetworkProvider::ConnectionChangedCallback> network_callbacks_; + std::vector<provider::Network::ConnectionChangedCallback> network_callbacks_; weave::Cloud* cloud_{nullptr}; @@ -418,7 +423,7 @@ InitDnsSd(); EXPECT_CALL(network_, GetConnectionState()) - .WillRepeatedly(Return(NetworkState::kConnected)); + .WillRepeatedly(Return(provider::NetworkState::kConnected)); } }; @@ -426,8 +431,8 @@ StartDevice(); // Short disconnect. - NotifyNetworkChanged(NetworkState::kOffline, {}); - NotifyNetworkChanged(NetworkState::kConnected, + NotifyNetworkChanged(provider::NetworkState::kOffline, {}); + NotifyNetworkChanged(provider::NetworkState::kConnected, base::TimeDelta::FromSeconds(10)); task_runner_.Run();