| Index: extensions/browser/api/socket/socket_api.h
|
| diff --git a/chrome/browser/extensions/api/socket/socket_api.h b/extensions/browser/api/socket/socket_api.h
|
| similarity index 86%
|
| rename from chrome/browser/extensions/api/socket/socket_api.h
|
| rename to extensions/browser/api/socket/socket_api.h
|
| index 950eb94dabc3fbac81b3bcbdd3078ca1739fc05c..5a43cab50e3a27d81b075d59325dd5159b19fb0a 100644
|
| --- a/chrome/browser/extensions/api/socket/socket_api.h
|
| +++ b/extensions/browser/api/socket/socket_api.h
|
| @@ -2,21 +2,21 @@
|
| // 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_SOCKET_SOCKET_API_H_
|
| -#define CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_API_H_
|
| +#ifndef EXTENSIONS_BROWSER_API_SOCKET_SOCKET_API_H_
|
| +#define EXTENSIONS_BROWSER_API_SOCKET_SOCKET_API_H_
|
| +
|
| +#include <string>
|
|
|
| #include "base/gtest_prod_util.h"
|
| #include "base/memory/ref_counted.h"
|
| #include "chrome/browser/extensions/api/api_resource_manager.h"
|
| -#include "chrome/common/extensions/api/socket.h"
|
| #include "extensions/browser/api/async_api_function.h"
|
| #include "extensions/browser/extension_function.h"
|
| +#include "extensions/common/api/socket.h"
|
| #include "net/base/address_list.h"
|
| #include "net/dns/host_resolver.h"
|
| #include "net/socket/tcp_client_socket.h"
|
|
|
| -#include <string>
|
| -
|
| namespace content {
|
| class BrowserContext;
|
| class ResourceContext;
|
| @@ -39,34 +39,31 @@ class SocketResourceManagerInterface {
|
| virtual ~SocketResourceManagerInterface() {}
|
|
|
| virtual bool SetBrowserContext(content::BrowserContext* context) = 0;
|
| - virtual int Add(Socket *socket) = 0;
|
| - virtual Socket* Get(const std::string& extension_id,
|
| - int api_resource_id) = 0;
|
| - virtual void Remove(const std::string& extension_id,
|
| - int api_resource_id) = 0;
|
| + virtual int Add(Socket* socket) = 0;
|
| + virtual Socket* Get(const std::string& extension_id, int api_resource_id) = 0;
|
| + virtual void Remove(const std::string& extension_id, int api_resource_id) = 0;
|
| virtual base::hash_set<int>* GetResourceIds(
|
| const std::string& extension_id) = 0;
|
| };
|
|
|
| // Implementation of SocketResourceManagerInterface using an
|
| // ApiResourceManager<T> instance (where T derives from Socket).
|
| -template<typename T>
|
| +template <typename T>
|
| class SocketResourceManager : public SocketResourceManagerInterface {
|
| public:
|
| - SocketResourceManager()
|
| - : manager_(NULL) {
|
| - }
|
| + SocketResourceManager() : manager_(NULL) {}
|
|
|
| virtual bool SetBrowserContext(content::BrowserContext* context) OVERRIDE {
|
| manager_ = ApiResourceManager<T>::Get(context);
|
| - DCHECK(manager_) << "There is no socket manager. "
|
| - "If this assertion is failing during a test, then it is likely that "
|
| - "TestExtensionSystem is failing to provide an instance of "
|
| - "ApiResourceManager<Socket>.";
|
| + DCHECK(manager_)
|
| + << "There is no socket manager. "
|
| + "If this assertion is failing during a test, then it is likely that "
|
| + "TestExtensionSystem is failing to provide an instance of "
|
| + "ApiResourceManager<Socket>.";
|
| return manager_ != NULL;
|
| }
|
|
|
| - virtual int Add(Socket *socket) OVERRIDE {
|
| + virtual int Add(Socket* socket) OVERRIDE {
|
| // Note: Cast needed here, because "T" may be a subclass of "Socket".
|
| return manager_->Add(static_cast<T*>(socket));
|
| }
|
| @@ -81,8 +78,8 @@ class SocketResourceManager : public SocketResourceManagerInterface {
|
| manager_->Remove(extension_id, api_resource_id);
|
| }
|
|
|
| - virtual base::hash_set<int>* GetResourceIds(
|
| - const std::string& extension_id) OVERRIDE {
|
| + virtual base::hash_set<int>* GetResourceIds(const std::string& extension_id)
|
| + OVERRIDE {
|
| return manager_->GetResourceIds(extension_id);
|
| }
|
|
|
| @@ -151,13 +148,9 @@ class SocketCreateFunction : public SocketAsyncApiFunction {
|
|
|
| private:
|
| FRIEND_TEST_ALL_PREFIXES(SocketUnitTest, Create);
|
| - enum SocketType {
|
| - kSocketTypeInvalid = -1,
|
| - kSocketTypeTCP,
|
| - kSocketTypeUDP
|
| - };
|
| + enum SocketType { kSocketTypeInvalid = -1, kSocketTypeTCP, kSocketTypeUDP };
|
|
|
| - scoped_ptr<api::socket::Create::Params> params_;
|
| + scoped_ptr<core_api::socket::Create::Params> params_;
|
| SocketType socket_type_;
|
| };
|
|
|
| @@ -248,7 +241,7 @@ class SocketListenFunction : public SocketAsyncApiFunction {
|
| virtual void Work() OVERRIDE;
|
|
|
| private:
|
| - scoped_ptr<api::socket::Listen::Params> params_;
|
| + scoped_ptr<core_api::socket::Listen::Params> params_;
|
| };
|
|
|
| class SocketAcceptFunction : public SocketAsyncApiFunction {
|
| @@ -265,8 +258,8 @@ class SocketAcceptFunction : public SocketAsyncApiFunction {
|
| virtual void AsyncWorkStart() OVERRIDE;
|
|
|
| private:
|
| - void OnAccept(int result_code, net::TCPClientSocket *socket);
|
| - scoped_ptr<api::socket::Accept::Params> params_;
|
| + void OnAccept(int result_code, net::TCPClientSocket* socket);
|
| + scoped_ptr<core_api::socket::Accept::Params> params_;
|
| };
|
|
|
| class SocketReadFunction : public SocketAsyncApiFunction {
|
| @@ -284,7 +277,7 @@ class SocketReadFunction : public SocketAsyncApiFunction {
|
| void OnCompleted(int result, scoped_refptr<net::IOBuffer> io_buffer);
|
|
|
| private:
|
| - scoped_ptr<api::socket::Read::Params> params_;
|
| + scoped_ptr<core_api::socket::Read::Params> params_;
|
| };
|
|
|
| class SocketWriteFunction : public SocketAsyncApiFunction {
|
| @@ -325,7 +318,7 @@ class SocketRecvFromFunction : public SocketAsyncApiFunction {
|
| int port);
|
|
|
| private:
|
| - scoped_ptr<api::socket::RecvFrom::Params> params_;
|
| + scoped_ptr<core_api::socket::RecvFrom::Params> params_;
|
| };
|
|
|
| class SocketSendToFunction : public SocketExtensionWithDnsLookupFunction {
|
| @@ -370,7 +363,7 @@ class SocketSetKeepAliveFunction : public SocketAsyncApiFunction {
|
| virtual void Work() OVERRIDE;
|
|
|
| private:
|
| - scoped_ptr<api::socket::SetKeepAlive::Params> params_;
|
| + scoped_ptr<core_api::socket::SetKeepAlive::Params> params_;
|
| };
|
|
|
| class SocketSetNoDelayFunction : public SocketAsyncApiFunction {
|
| @@ -387,7 +380,7 @@ class SocketSetNoDelayFunction : public SocketAsyncApiFunction {
|
| virtual void Work() OVERRIDE;
|
|
|
| private:
|
| - scoped_ptr<api::socket::SetNoDelay::Params> params_;
|
| + scoped_ptr<core_api::socket::SetNoDelay::Params> params_;
|
| };
|
|
|
| class SocketGetInfoFunction : public SocketAsyncApiFunction {
|
| @@ -404,7 +397,7 @@ class SocketGetInfoFunction : public SocketAsyncApiFunction {
|
| virtual void Work() OVERRIDE;
|
|
|
| private:
|
| - scoped_ptr<api::socket::GetInfo::Params> params_;
|
| + scoped_ptr<core_api::socket::GetInfo::Params> params_;
|
| };
|
|
|
| class SocketGetNetworkListFunction : public AsyncExtensionFunction {
|
| @@ -435,7 +428,7 @@ class SocketJoinGroupFunction : public SocketAsyncApiFunction {
|
| virtual void Work() OVERRIDE;
|
|
|
| private:
|
| - scoped_ptr<api::socket::JoinGroup::Params> params_;
|
| + scoped_ptr<core_api::socket::JoinGroup::Params> params_;
|
| };
|
|
|
| class SocketLeaveGroupFunction : public SocketAsyncApiFunction {
|
| @@ -452,7 +445,7 @@ class SocketLeaveGroupFunction : public SocketAsyncApiFunction {
|
| virtual void Work() OVERRIDE;
|
|
|
| private:
|
| - scoped_ptr<api::socket::LeaveGroup::Params> params_;
|
| + scoped_ptr<core_api::socket::LeaveGroup::Params> params_;
|
| };
|
|
|
| class SocketSetMulticastTimeToLiveFunction : public SocketAsyncApiFunction {
|
| @@ -470,7 +463,7 @@ class SocketSetMulticastTimeToLiveFunction : public SocketAsyncApiFunction {
|
| virtual void Work() OVERRIDE;
|
|
|
| private:
|
| - scoped_ptr<api::socket::SetMulticastTimeToLive::Params> params_;
|
| + scoped_ptr<core_api::socket::SetMulticastTimeToLive::Params> params_;
|
| };
|
|
|
| class SocketSetMulticastLoopbackModeFunction : public SocketAsyncApiFunction {
|
| @@ -488,7 +481,7 @@ class SocketSetMulticastLoopbackModeFunction : public SocketAsyncApiFunction {
|
| virtual void Work() OVERRIDE;
|
|
|
| private:
|
| - scoped_ptr<api::socket::SetMulticastLoopbackMode::Params> params_;
|
| + scoped_ptr<core_api::socket::SetMulticastLoopbackMode::Params> params_;
|
| };
|
|
|
| class SocketGetJoinedGroupsFunction : public SocketAsyncApiFunction {
|
| @@ -506,8 +499,8 @@ class SocketGetJoinedGroupsFunction : public SocketAsyncApiFunction {
|
| virtual void Work() OVERRIDE;
|
|
|
| private:
|
| - scoped_ptr<api::socket::GetJoinedGroups::Params> params_;
|
| + scoped_ptr<core_api::socket::GetJoinedGroups::Params> params_;
|
| };
|
| } // namespace extensions
|
|
|
| -#endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_API_H_
|
| +#endif // EXTENSIONS_BROWSER_API_SOCKET_SOCKET_API_H_
|
|
|