Index: chrome/browser/extensions/api/networking_private/networking_private_process_client.h |
diff --git a/chrome/browser/extensions/api/networking_private/networking_private_process_client.h b/chrome/browser/extensions/api/networking_private/networking_private_process_client.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..87e029b0305ffc2923288c76e27cd1aeabe9f16b |
--- /dev/null |
+++ b/chrome/browser/extensions/api/networking_private/networking_private_process_client.h |
@@ -0,0 +1,156 @@ |
+// Copyright (c) 2012 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 CHROME_BROWSER_EXTENSIONS_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_PROCESS_CLIENT_H_ |
+#define CHROME_BROWSER_EXTENSIONS_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_PROCESS_CLIENT_H_ |
+ |
+#include <string> |
+#include <vector> |
+ |
+#include "base/basictypes.h" |
+#include "base/compiler_specific.h" |
+#include "base/memory/weak_ptr.h" |
+#include "base/strings/string16.h" |
+#include "base/supports_user_data.h" |
+#include "base/values.h" |
+#include "content/public/browser/browser_thread.h" |
+#include "content/public/browser/utility_process_host.h" |
+#include "content/public/browser/utility_process_host_client.h" |
+ |
+class Profile; |
+ |
+// This class is the client for the out of process networking private handler. |
+class NetworkingPrivateProcessClient |
+ : public content::UtilityProcessHostClient { |
+ public: |
+ // An error callback used by both the configuration handler and the state |
+ // handler to receive error results from the API. |
+ typedef base::Callback<void(const std::string& error_name, |
+ scoped_ptr<base::DictionaryValue> error_data)> |
+ ErrorCallback; |
+ |
+ typedef base::Callback<void(const std::string& network_guid, |
+ const base::DictionaryValue& dictionary)> |
+ DictionaryResultCallback; |
+ |
+ typedef base::Callback<void(const base::ListValue& network_list)> |
+ ListResultCallback; |
+ |
+ typedef base::Callback<void(const std::string& network_guid)> |
+ StringResultCallback; |
+ |
+ typedef base::Callback<void()> VoidResultCallback; |
+ |
+ explicit NetworkingPrivateProcessClient(Profile* profile); |
+ |
+ // Launches the task to start the external process. |
+ void Start(); |
+ |
+ // UtilityProcessHostClient implementation: |
+ virtual void OnProcessCrashed(int exit_code) OVERRIDE; |
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
+ |
+ // Gets the properties of the network with id |service_path|. See note on |
+ // |callback| and |error_callback|, in class description above. |
+ void GetProperties(const std::string& service_path, |
+ const DictionaryResultCallback& callback, |
+ const ErrorCallback& error_callback); |
+ |
+ // Start connect to the network with id |service_path|. See note on |
+ // |callback| and |error_callback|, in class description above. |
+ void StartConnect(const std::string& service_path, |
+ const VoidResultCallback& callback, |
+ const ErrorCallback& error_callback); |
+ |
+ // Start disconnect from the network with id |service_path|. See note on |
+ // |callback| and |error_callback|, in class description above. |
+ void StartDisconnect(const std::string& service_path, |
+ const VoidResultCallback& callback, |
+ const ErrorCallback& error_callback); |
+ |
+ // Sets the |properties| of the network with id |service_path|. See note on |
+ // |callback| and |error_callback|, in class description above. |
+ void SetProperties(const std::string& service_path, |
+ const base::DictionaryValue& properties, |
+ const VoidResultCallback& callback, |
+ const ErrorCallback& error_callback); |
+ |
+ // Requests network scan. Broadcasts NetworkListChangedEvent upon completion. |
+ void RequestNetworkScan(); |
+ |
+ // Gets the list of visible networks and calls |callback|. |
+ void GetVisibleNetworks(const ListResultCallback& callback); |
+ |
+ // Message handlers |
+ void OnGetPropertiesStart(const std::string& network_guid); |
+ void OnGetPropertiesSucceeded(const std::string& network_guid, |
+ const base::DictionaryValue& properties); |
+ void OnGetPropertiesFailed(const std::string& error_code, |
+ const base::DictionaryValue& error_data); |
+ |
+ void OnStartConnectStart(const std::string& network_guid); |
+ void OnStartConnectSucceeded(const std::string& network_guid); |
+ void OnStartConnectFailed(const std::string& error_code, |
+ const base::DictionaryValue& error_data); |
+ |
+ void OnStartDisconnectStart(const std::string& network_guid); |
+ void OnStartDisconnectSucceeded(const std::string& network_guid); |
+ void OnStartDisconnectFailed(const std::string& error_code, |
+ const base::DictionaryValue& error_data); |
+ |
+ void OnSetPropertiesStart(const std::string& network_guid, |
+ scoped_ptr<base::DictionaryValue> properties); |
+ void OnSetPropertiesSucceeded(const std::string& network_guid); |
+ void OnSetPropertiesFailed(const std::string& error_code, |
+ const base::DictionaryValue& error_data); |
+ |
+ void OnRequestNetworkScan(); |
+ |
+ void OnGetVisibleNetworks(); |
+ void OnGetVisibleNetworksSucceeded(const base::ListValue& network_list); |
+ |
+ void OnNetworksChangedEvent(const std::vector<std::string>& network_guids); |
+ void OnNetworkListChangedEvent(const std::vector<std::string>& network_guids); |
+ |
+ protected: |
+ virtual ~NetworkingPrivateProcessClient(); |
+ |
+ private: |
+ // Notifies the importerhost that import has finished, and calls Release(). |
+ void Cleanup(); |
+ |
+ // Creates a new UtilityProcessHost, which launches the import process. |
+ void StartProcessOnIOThread(content::BrowserThread::ID thread_id); |
+ |
+ // Notifications received from the ProfileImportProcessHost are passed back |
+ // to process_importer_host_, which calls the ProfileWriter to record the |
+ // import data. When the import process is done, process_importer_host_ |
+ // deletes itself. |
+ // ExternalProcessImporterHost* process_importer_host_; |
stevenjb
2013/08/13 23:39:04
??
mef
2013/08/21 17:25:34
Leftovers from the class that I've used for inspir
mef
2013/09/24 21:14:37
Done.
|
+ |
+ // Handles sending messages to the external process. Deletes itself when |
+ // the external process dies (see |
+ // BrowserChildProcessHost::OnChildDisconnected). |
+ base::WeakPtr<content::UtilityProcessHost> utility_process_host_; |
+ |
+ DictionaryResultCallback get_properties_success_callback_; |
+ ErrorCallback get_properties_error_callback_; |
+ |
+ VoidResultCallback start_connect_success_callback_; |
+ ErrorCallback start_connect_error_callback_; |
+ |
+ VoidResultCallback start_disconnect_success_callback_; |
+ ErrorCallback start_disconnect_error_callback_; |
+ |
+ VoidResultCallback set_properties_success_callback_; |
+ ErrorCallback set_properties_error_callback_; |
+ |
+ ListResultCallback get_visible_networks_callback_; |
+ |
+ Profile* profile_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateProcessClient); |
+}; |
+ |
+#endif // CHROME_BROWSER_EXTENSIONS_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_PROCESS_CLIENT_H_ |