summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/common/pepper_messages.cc2
-rw-r--r--chrome/common/render_messages.h1
-rw-r--r--chrome/renderer/pepper_plugin_delegate_impl.cc2
-rw-r--r--chrome/renderer/render_view.cc2
-rw-r--r--content/browser/renderer_host/pepper_message_filter.cc3
-rw-r--r--content/browser/renderer_host/pepper_message_filter.h2
-rw-r--r--ppapi/c/private/ppb_flash.h38
-rw-r--r--ppapi/c/private/ppb_flash_net_connector.h46
-rw-r--r--ppapi/cpp/private/flash_net_connector.cc (renamed from ppapi/cpp/private/flash.cc)2
-rw-r--r--ppapi/cpp/private/flash_net_connector.h (renamed from ppapi/cpp/private/flash.h)14
-rw-r--r--ppapi/ppapi_cpp.gypi1
-rw-r--r--webkit/glue/webkit_glue.gypi2
-rw-r--r--webkit/plugins/ppapi/plugin_module.cc2
-rw-r--r--webkit/plugins/ppapi/ppb_flash_impl.cc194
-rw-r--r--webkit/plugins/ppapi/ppb_flash_impl.h44
-rw-r--r--webkit/plugins/ppapi/ppb_flash_net_connector_impl.cc205
-rw-r--r--webkit/plugins/ppapi/ppb_flash_net_connector_impl.h61
17 files changed, 335 insertions, 286 deletions
diff --git a/chrome/common/pepper_messages.cc b/chrome/common/pepper_messages.cc
index 60dad0d..807618d 100644
--- a/chrome/common/pepper_messages.cc
+++ b/chrome/common/pepper_messages.cc
@@ -3,7 +3,7 @@
// found in the LICENSE file.
#include "chrome/common/common_param_traits.h"
-#include "ppapi/c/private/ppb_flash.h"
+#include "ppapi/c/private/ppb_flash_net_connector.h"
#define IPC_MESSAGE_IMPL
#include "chrome/common/pepper_messages.h"
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index 40fa895..3e0f9ba 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -72,7 +72,6 @@ class SkBitmap;
class URLPattern;
struct ContextMenuParams;
struct EditCommand;
-struct PP_Flash_NetAddress;
struct ResourceResponseHead;
struct SyncLoadResult;
struct RendererPreferences;
diff --git a/chrome/renderer/pepper_plugin_delegate_impl.cc b/chrome/renderer/pepper_plugin_delegate_impl.cc
index fd4a2dd..50dcd3d 100644
--- a/chrome/renderer/pepper_plugin_delegate_impl.cc
+++ b/chrome/renderer/pepper_plugin_delegate_impl.cc
@@ -36,6 +36,7 @@
#include "ppapi/c/dev/pp_video_dev.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/private/ppb_flash.h"
+#include "ppapi/c/private/ppb_flash_net_connector.h"
#include "ppapi/proxy/host_dispatcher.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserCompletion.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams.h"
@@ -50,6 +51,7 @@
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/ppb_flash_impl.h"
+#include "webkit/plugins/ppapi/ppb_flash_net_connector_impl.h"
#if defined(OS_MACOSX)
#include "chrome/renderer/render_thread.h"
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index a7d7bcb..cd0444e 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -112,7 +112,7 @@
#include "net/base/escape.h"
#include "net/base/net_errors.h"
#include "net/http/http_util.h"
-#include "ppapi/c/private/ppb_flash.h"
+#include "ppapi/c/private/ppb_flash_net_connector.h"
#include "skia/ext/bitmap_platform_device.h"
#include "skia/ext/image_operations.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityCache.h"
diff --git a/content/browser/renderer_host/pepper_message_filter.cc b/content/browser/renderer_host/pepper_message_filter.cc
index 6a77171..ae582ad 100644
--- a/content/browser/renderer_host/pepper_message_filter.cc
+++ b/content/browser/renderer_host/pepper_message_filter.cc
@@ -16,7 +16,8 @@
#include "net/base/host_port_pair.h"
#include "net/base/host_resolver.h"
#include "net/url_request/url_request_context.h"
-#include "webkit/plugins/ppapi/ppb_flash_impl.h"
+#include "ppapi/c/private/ppb_flash_net_connector.h"
+#include "webkit/plugins/ppapi/ppb_flash_net_connector_impl.h"
#if defined(ENABLE_FLAPPER_HACKS)
#include <netdb.h>
diff --git a/content/browser/renderer_host/pepper_message_filter.h b/content/browser/renderer_host/pepper_message_filter.h
index 31f920c..1a1e4da 100644
--- a/content/browser/renderer_host/pepper_message_filter.h
+++ b/content/browser/renderer_host/pepper_message_filter.h
@@ -12,7 +12,7 @@
#include "base/process.h"
#include "chrome/browser/browser_message_filter.h"
#include "ipc/ipc_channel_proxy.h"
-#include "ppapi/c/private/ppb_flash.h"
+#include "ppapi/c/private/ppb_flash_net_connector.h"
class Profile;
class URLRequestContextGetter;
diff --git a/ppapi/c/private/ppb_flash.h b/ppapi/c/private/ppb_flash.h
index 4825fe4..c602278 100644
--- a/ppapi/c/private/ppb_flash.h
+++ b/ppapi/c/private/ppb_flash.h
@@ -10,15 +10,12 @@
#endif
#include "ppapi/c/pp_bool.h"
-#include "ppapi/c/pp_errors.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_point.h"
#include "ppapi/c/pp_rect.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_var.h"
-// PPB_Flash -------------------------------------------------------------------
-
#define PPB_FLASH_INTERFACE "PPB_Flash;6"
#ifdef _WIN32
@@ -129,39 +126,4 @@ struct PPB_Flash {
void (*QuitMessageLoop)(PP_Instance instance);
};
-// PPB_Flash_NetConnector ------------------------------------------------------
-
-#define PPB_FLASH_NETCONNECTOR_INTERFACE "PPB_Flash_NetConnector;1"
-
-// This is an opaque type holding a network address.
-struct PP_Flash_NetAddress {
- size_t size;
- char data[128];
-};
-
-struct PPB_Flash_NetConnector {
- PP_Resource (*Create)(PP_Instance instance_id);
- PP_Bool (*IsFlashNetConnector)(PP_Resource resource_id);
-
- // Connect to a TCP port given as a host-port pair. The local and remote
- // addresses of the connection (if successful) are returned in
- // |local_addr_out| and |remote_addr_out|, respectively, if non-null.
- int32_t (*ConnectTcp)(PP_Resource connector_id,
- const char* host,
- uint16_t port,
- PP_FileHandle* socket_out,
- struct PP_Flash_NetAddress* local_addr_out,
- struct PP_Flash_NetAddress* remote_addr_out,
- struct PP_CompletionCallback callback);
-
- // Same as |ConnectTcp()|, but connecting to the address given by |addr|. A
- // typical use-case would be for reconnections.
- int32_t (*ConnectTcpAddress)(PP_Resource connector_id,
- const struct PP_Flash_NetAddress* addr,
- PP_FileHandle* socket_out,
- struct PP_Flash_NetAddress* local_addr_out,
- struct PP_Flash_NetAddress* remote_addr_out,
- struct PP_CompletionCallback callback);
-};
-
#endif // PPAPI_C_PRIVATE_PPB_FLASH_H_
diff --git a/ppapi/c/private/ppb_flash_net_connector.h b/ppapi/c/private/ppb_flash_net_connector.h
new file mode 100644
index 0000000..3ca6411
--- /dev/null
+++ b/ppapi/c/private/ppb_flash_net_connector.h
@@ -0,0 +1,46 @@
+// Copyright (c) 2011 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 PPAPI_C_PRIVATE_PPB_FLASH_NET_CONNECTOR_H_
+#define PPAPI_C_PRIVATE_PPB_FLASH_NET_CONNECTOR_H_
+
+#include "ppapi/c/pp_bool.h"
+#include "ppapi/c/pp_instance.h"
+#include "ppapi/c/pp_resource.h"
+#include "ppapi/c/private/ppb_flash.h" // For |PP_FileHandle|.
+
+#define PPB_FLASH_NETCONNECTOR_INTERFACE "PPB_Flash_NetConnector;1"
+
+// This is an opaque type holding a network address.
+struct PP_Flash_NetAddress {
+ size_t size;
+ char data[128];
+};
+
+struct PPB_Flash_NetConnector {
+ PP_Resource (*Create)(PP_Instance instance_id);
+ PP_Bool (*IsFlashNetConnector)(PP_Resource resource_id);
+
+ // Connect to a TCP port given as a host-port pair. The local and remote
+ // addresses of the connection (if successful) are returned in
+ // |local_addr_out| and |remote_addr_out|, respectively, if non-null.
+ int32_t (*ConnectTcp)(PP_Resource connector_id,
+ const char* host,
+ uint16_t port,
+ PP_FileHandle* socket_out,
+ struct PP_Flash_NetAddress* local_addr_out,
+ struct PP_Flash_NetAddress* remote_addr_out,
+ struct PP_CompletionCallback callback);
+
+ // Same as |ConnectTcp()|, but connecting to the address given by |addr|. A
+ // typical use-case would be for reconnections.
+ int32_t (*ConnectTcpAddress)(PP_Resource connector_id,
+ const struct PP_Flash_NetAddress* addr,
+ PP_FileHandle* socket_out,
+ struct PP_Flash_NetAddress* local_addr_out,
+ struct PP_Flash_NetAddress* remote_addr_out,
+ struct PP_CompletionCallback callback);
+};
+
+#endif // PPAPI_C_PRIVATE_PPB_FLASH_NET_CONNECTOR_H_
diff --git a/ppapi/cpp/private/flash.cc b/ppapi/cpp/private/flash_net_connector.cc
index 5af96bc..8896114 100644
--- a/ppapi/cpp/private/flash.cc
+++ b/ppapi/cpp/private/flash_net_connector.cc
@@ -4,7 +4,7 @@
// TODO(viettrungluu): See the comment in corresponding .h file.
-#include "ppapi/cpp/private/flash.h"
+#include "ppapi/cpp/private/flash_net_connector.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/cpp/completion_callback.h"
diff --git a/ppapi/cpp/private/flash.h b/ppapi/cpp/private/flash_net_connector.h
index ffd1353..56df193 100644
--- a/ppapi/cpp/private/flash.h
+++ b/ppapi/cpp/private/flash_net_connector.h
@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// TODO(viettrungluu): This (and the .cc file) contain C++ wrappers for some
-// things in ppapi/c/private/ppb_flash.h. This is currently not used in (or even
-// compiled with) Chromium.
+// TODO(viettrungluu): This (and the .cc file) contain C++ wrappers for things
+// in ppapi/c/private/ppb_flash_net_connector.h. This is currently not used in
+// (or even compiled with) Chromium.
-#ifndef PPAPI_CPP_PRIVATE_FLASH_H_
-#define PPAPI_CPP_PRIVATE_FLASH_H_
+#ifndef PPAPI_CPP_PRIVATE_FLASH_NET_CONNECTOR_H_
+#define PPAPI_CPP_PRIVATE_FLASH_NET_CONNECTOR_H_
-#include "ppapi/c/private/ppb_flash.h"
+#include "ppapi/c/private/ppb_flash_net_connector.h"
#include "ppapi/cpp/resource.h"
namespace pp {
@@ -39,4 +39,4 @@ class NetConnector : public Resource {
} // namespace flash
} // namespace pp
-#endif // PPAPI_CPP_PRIVATE_FLASH_H_
+#endif // PPAPI_CPP_PRIVATE_FLASH_NET_CONNECTOR_H_
diff --git a/ppapi/ppapi_cpp.gypi b/ppapi/ppapi_cpp.gypi
index 05efe6b..36840d9 100644
--- a/ppapi/ppapi_cpp.gypi
+++ b/ppapi/ppapi_cpp.gypi
@@ -83,6 +83,7 @@
# Private interfaces.
'c/private/ppb_flash.h',
'c/private/ppb_flash_menu.h',
+ 'c/private/ppb_flash_net_connector.h',
'c/private/ppb_nacl_private.h',
'c/private/ppb_pdf.h',
'c/private/ppb_proxy_private.h',
diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi
index c3bb964..f164c6a 100644
--- a/webkit/glue/webkit_glue.gypi
+++ b/webkit/glue/webkit_glue.gypi
@@ -300,6 +300,8 @@
'../plugins/ppapi/ppb_flash_impl_linux.cc',
'../plugins/ppapi/ppb_flash_menu_impl.cc',
'../plugins/ppapi/ppb_flash_menu_impl.h',
+ '../plugins/ppapi/ppb_flash_net_connector_impl.cc',
+ '../plugins/ppapi/ppb_flash_net_connector_impl.h',
'../plugins/ppapi/ppb_font_impl.cc',
'../plugins/ppapi/ppb_font_impl.h',
'../plugins/ppapi/ppb_gles_chromium_texture_mapping_impl.cc',
diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc
index 4e852c1..a20fe45 100644
--- a/webkit/plugins/ppapi/plugin_module.cc
+++ b/webkit/plugins/ppapi/plugin_module.cc
@@ -51,6 +51,7 @@
#include "ppapi/c/ppp_instance.h"
#include "ppapi/c/private/ppb_flash.h"
#include "ppapi/c/private/ppb_flash_menu.h"
+#include "ppapi/c/private/ppb_flash_net_connector.h"
#include "ppapi/c/private/ppb_pdf.h"
#include "ppapi/c/private/ppb_proxy_private.h"
#include "ppapi/c/private/ppb_nacl_private.h"
@@ -70,6 +71,7 @@
#include "webkit/plugins/ppapi/ppb_file_system_impl.h"
#include "webkit/plugins/ppapi/ppb_flash_impl.h"
#include "webkit/plugins/ppapi/ppb_flash_menu_impl.h"
+#include "webkit/plugins/ppapi/ppb_flash_net_connector_impl.h"
#include "webkit/plugins/ppapi/ppb_font_impl.h"
#include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h"
#include "webkit/plugins/ppapi/ppb_image_data_impl.h"
diff --git a/webkit/plugins/ppapi/ppb_flash_impl.cc b/webkit/plugins/ppapi/ppb_flash_impl.cc
index 2a922c0..4c439b0 100644
--- a/webkit/plugins/ppapi/ppb_flash_impl.cc
+++ b/webkit/plugins/ppapi/ppb_flash_impl.cc
@@ -6,9 +6,10 @@
#include <string.h>
+#include <string>
+
#include "base/file_path.h"
#include "base/message_loop.h"
-#include "base/stringprintf.h"
#include "base/utf_string_conversions.h"
#include "googleurl/src/gurl.h"
#include "ppapi/c/dev/pp_file_info_dev.h"
@@ -20,13 +21,12 @@
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
+#include "webkit/plugins/ppapi/resource_tracker.h"
#include "webkit/plugins/ppapi/var.h"
namespace webkit {
namespace ppapi {
-// PPB_Flash_Impl --------------------------------------------------------------
-
namespace {
void SetInstanceAlwaysOnTop(PP_Instance pp_instance, PP_Bool on_top) {
@@ -252,193 +252,5 @@ const PPB_Flash* PPB_Flash_Impl::GetInterface() {
return &ppb_flash;
}
-// PPB_Flash_NetConnector_Impl -------------------------------------------------
-
-namespace {
-
-PP_Resource Create(PP_Instance instance_id) {
- PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
- if (!instance)
- return 0;
-
- scoped_refptr<PPB_Flash_NetConnector_Impl> connector(
- new PPB_Flash_NetConnector_Impl(instance));
- return connector->GetReference();
-}
-
-PP_Bool IsFlashNetConnector(PP_Resource resource) {
- return BoolToPPBool(!!Resource::GetAs<PPB_Flash_NetConnector_Impl>(resource));
-}
-
-int32_t ConnectTcp(PP_Resource connector_id,
- const char* host,
- uint16_t port,
- PP_FileHandle* socket_out,
- PP_Flash_NetAddress* local_addr_out,
- PP_Flash_NetAddress* remote_addr_out,
- PP_CompletionCallback callback) {
- scoped_refptr<PPB_Flash_NetConnector_Impl> connector(
- Resource::GetAs<PPB_Flash_NetConnector_Impl>(connector_id));
- if (!connector.get())
- return PP_ERROR_BADRESOURCE;
-
- return connector->ConnectTcp(
- host, port, socket_out, local_addr_out, remote_addr_out, callback);
-}
-
-int32_t ConnectTcpAddress(PP_Resource connector_id,
- const PP_Flash_NetAddress* addr,
- PP_FileHandle* socket_out,
- PP_Flash_NetAddress* local_addr_out,
- PP_Flash_NetAddress* remote_addr_out,
- PP_CompletionCallback callback) {
- scoped_refptr<PPB_Flash_NetConnector_Impl> connector(
- Resource::GetAs<PPB_Flash_NetConnector_Impl>(connector_id));
- if (!connector.get())
- return PP_ERROR_BADRESOURCE;
-
- return connector->ConnectTcpAddress(
- addr, socket_out, local_addr_out, remote_addr_out, callback);
-}
-
-const PPB_Flash_NetConnector ppb_flash_netconnector = {
- &Create,
- &IsFlashNetConnector,
- &ConnectTcp,
- &ConnectTcpAddress,
-};
-
-} // namespace
-
-PPB_Flash_NetConnector_Impl::PPB_Flash_NetConnector_Impl(
- PluginInstance* instance)
- : Resource(instance) {
-}
-
-PPB_Flash_NetConnector_Impl::~PPB_Flash_NetConnector_Impl() {
-}
-
-// static
-const PPB_Flash_NetConnector* PPB_Flash_NetConnector_Impl::GetInterface() {
- return &ppb_flash_netconnector;
-}
-
-PPB_Flash_NetConnector_Impl*
- PPB_Flash_NetConnector_Impl::AsPPB_Flash_NetConnector_Impl() {
- return this;
-}
-
-int32_t PPB_Flash_NetConnector_Impl::ConnectTcp(
- const char* host,
- uint16_t port,
- PP_FileHandle* socket_out,
- PP_Flash_NetAddress* local_addr_out,
- PP_Flash_NetAddress* remote_addr_out,
- PP_CompletionCallback callback) {
- // |socket_out| is not optional.
- if (!socket_out)
- return PP_ERROR_BADARGUMENT;
-
- if (!callback.func) {
- NOTIMPLEMENTED();
- return PP_ERROR_BADARGUMENT;
- }
-
- if (callback_.get() && !callback_->completed())
- return PP_ERROR_INPROGRESS;
-
- PP_Resource resource_id = GetReferenceNoAddRef();
- if (!resource_id) {
- NOTREACHED();
- return PP_ERROR_FAILED;
- }
-
- int32_t rv = instance()->delegate()->ConnectTcp(this, host, port);
- if (rv == PP_ERROR_WOULDBLOCK) {
- // Record callback and output buffers.
- callback_ = new TrackedCompletionCallback(
- instance()->module()->GetCallbackTracker(), resource_id, callback);
- socket_out_ = socket_out;
- local_addr_out_ = local_addr_out;
- remote_addr_out_ = remote_addr_out;
- } else {
- // This should never be completed synchronously successfully.
- DCHECK_NE(rv, PP_OK);
- }
- return rv;
-}
-
-int32_t PPB_Flash_NetConnector_Impl::ConnectTcpAddress(
- const PP_Flash_NetAddress* addr,
- PP_FileHandle* socket_out,
- PP_Flash_NetAddress* local_addr_out,
- PP_Flash_NetAddress* remote_addr_out,
- PP_CompletionCallback callback) {
- // |socket_out| is not optional.
- if (!socket_out)
- return PP_ERROR_BADARGUMENT;
-
- if (!callback.func) {
- NOTIMPLEMENTED();
- return PP_ERROR_BADARGUMENT;
- }
-
- if (callback_.get() && !callback_->completed())
- return PP_ERROR_INPROGRESS;
-
- PP_Resource resource_id = GetReferenceNoAddRef();
- if (!resource_id) {
- NOTREACHED();
- return PP_ERROR_FAILED;
- }
-
- int32_t rv = instance()->delegate()->ConnectTcpAddress(this, addr);
- if (rv == PP_ERROR_WOULDBLOCK) {
- // Record callback and output buffers.
- callback_ = new TrackedCompletionCallback(
- instance()->module()->GetCallbackTracker(), resource_id, callback);
- socket_out_ = socket_out;
- local_addr_out_ = local_addr_out;
- remote_addr_out_ = remote_addr_out;
- } else {
- // This should never be completed synchronously successfully.
- DCHECK_NE(rv, PP_OK);
- }
- return rv;
-}
-
-void PPB_Flash_NetConnector_Impl::CompleteConnectTcp(
- PP_FileHandle socket,
- const PP_Flash_NetAddress& local_addr,
- const PP_Flash_NetAddress& remote_addr) {
- int32_t rv = PP_ERROR_ABORTED;
- if (!callback_->aborted()) {
- CHECK(!callback_->completed());
-
- // Write output data.
- *socket_out_ = socket;
- if (socket != PP_kInvalidFileHandle) {
- if (local_addr_out_)
- *local_addr_out_ = local_addr;
- if (remote_addr_out_)
- *remote_addr_out_ = remote_addr;
- rv = PP_OK;
- } else {
- rv = PP_ERROR_FAILED;
- }
- }
-
- // Theoretically, the plugin should be allowed to try another |ConnectTcp()|
- // from the callback.
- scoped_refptr<TrackedCompletionCallback> callback;
- callback.swap(callback_);
- // Wipe everything else out for safety.
- socket_out_ = NULL;
- local_addr_out_ = NULL;
- remote_addr_out_ = NULL;
-
- callback->Run(rv); // Will complete abortively if necessary.
-}
-
} // namespace ppapi
} // namespace webkit
diff --git a/webkit/plugins/ppapi/ppb_flash_impl.h b/webkit/plugins/ppapi/ppb_flash_impl.h
index 8b02dee..45d04d0 100644
--- a/webkit/plugins/ppapi/ppb_flash_impl.h
+++ b/webkit/plugins/ppapi/ppb_flash_impl.h
@@ -6,13 +6,10 @@
#define WEBKIT_PLUGINS_PPAPI_PPB_FLASH_IMPL_H_
#include "base/basictypes.h"
-#include "base/ref_counted.h"
#include "build/build_config.h"
#include "ppapi/c/pp_point.h"
#include "ppapi/c/pp_rect.h"
#include "ppapi/c/private/ppb_flash.h"
-#include "webkit/plugins/ppapi/callbacks.h"
-#include "webkit/plugins/ppapi/resource.h"
namespace webkit {
namespace ppapi {
@@ -43,47 +40,6 @@ class PPB_Flash_Impl {
DISALLOW_COPY_AND_ASSIGN(PPB_Flash_Impl);
};
-class PPB_Flash_NetConnector_Impl : public Resource {
- public:
- explicit PPB_Flash_NetConnector_Impl(PluginInstance* instance);
- virtual ~PPB_Flash_NetConnector_Impl();
-
- static const PPB_Flash_NetConnector* GetInterface();
-
- // Resource override.
- virtual PPB_Flash_NetConnector_Impl* AsPPB_Flash_NetConnector_Impl();
-
- // PPB_Flash_NetConnector implementation.
- int32_t ConnectTcp(const char* host,
- uint16_t port,
- PP_FileHandle* socket_out,
- PP_Flash_NetAddress* local_addr_out,
- PP_Flash_NetAddress* remote_addr_out,
- PP_CompletionCallback callback);
- int32_t ConnectTcpAddress(const PP_Flash_NetAddress* addr,
- PP_FileHandle* socket_out,
- PP_Flash_NetAddress* local_addr_out,
- PP_Flash_NetAddress* remote_addr_out,
- PP_CompletionCallback callback);
-
- // Called to complete |ConnectTcp()| and |ConnectTcpAddress()|.
- void CompleteConnectTcp(PP_FileHandle socket,
- const PP_Flash_NetAddress& local_addr,
- const PP_Flash_NetAddress& remote_addr);
-
- private:
- // Any pending callback (for |ConnectTcp()| or |ConnectTcpAddress()|).
- scoped_refptr<TrackedCompletionCallback> callback_;
-
- // Output buffers to be filled in when the callback is completed successfully
- // (|{local,remote}_addr_out| are optional and may be null).
- PP_FileHandle* socket_out_;
- PP_Flash_NetAddress* local_addr_out_;
- PP_Flash_NetAddress* remote_addr_out_;
-
- DISALLOW_COPY_AND_ASSIGN(PPB_Flash_NetConnector_Impl);
-};
-
} // namespace ppapi
} // namespace webkit
diff --git a/webkit/plugins/ppapi/ppb_flash_net_connector_impl.cc b/webkit/plugins/ppapi/ppb_flash_net_connector_impl.cc
new file mode 100644
index 0000000..c817c8e
--- /dev/null
+++ b/webkit/plugins/ppapi/ppb_flash_net_connector_impl.cc
@@ -0,0 +1,205 @@
+// Copyright (c) 2011 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.
+
+#include "webkit/plugins/ppapi/ppb_flash_net_connector_impl.h"
+
+#include "ppapi/c/pp_completion_callback.h"
+#include "ppapi/c/private/ppb_flash_net_connector.h"
+#include "webkit/plugins/ppapi/common.h"
+#include "webkit/plugins/ppapi/plugin_delegate.h"
+#include "webkit/plugins/ppapi/plugin_module.h"
+#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
+
+namespace webkit {
+namespace ppapi {
+
+namespace {
+
+PP_Resource Create(PP_Instance instance_id) {
+ PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
+ if (!instance)
+ return 0;
+
+ scoped_refptr<PPB_Flash_NetConnector_Impl> connector(
+ new PPB_Flash_NetConnector_Impl(instance));
+ return connector->GetReference();
+}
+
+PP_Bool IsFlashNetConnector(PP_Resource resource) {
+ return BoolToPPBool(!!Resource::GetAs<PPB_Flash_NetConnector_Impl>(resource));
+}
+
+int32_t ConnectTcp(PP_Resource connector_id,
+ const char* host,
+ uint16_t port,
+ PP_FileHandle* socket_out,
+ PP_Flash_NetAddress* local_addr_out,
+ PP_Flash_NetAddress* remote_addr_out,
+ PP_CompletionCallback callback) {
+ scoped_refptr<PPB_Flash_NetConnector_Impl> connector(
+ Resource::GetAs<PPB_Flash_NetConnector_Impl>(connector_id));
+ if (!connector.get())
+ return PP_ERROR_BADRESOURCE;
+
+ return connector->ConnectTcp(
+ host, port, socket_out, local_addr_out, remote_addr_out, callback);
+}
+
+int32_t ConnectTcpAddress(PP_Resource connector_id,
+ const PP_Flash_NetAddress* addr,
+ PP_FileHandle* socket_out,
+ PP_Flash_NetAddress* local_addr_out,
+ PP_Flash_NetAddress* remote_addr_out,
+ PP_CompletionCallback callback) {
+ scoped_refptr<PPB_Flash_NetConnector_Impl> connector(
+ Resource::GetAs<PPB_Flash_NetConnector_Impl>(connector_id));
+ if (!connector.get())
+ return PP_ERROR_BADRESOURCE;
+
+ return connector->ConnectTcpAddress(
+ addr, socket_out, local_addr_out, remote_addr_out, callback);
+}
+
+const PPB_Flash_NetConnector ppb_flash_netconnector = {
+ &Create,
+ &IsFlashNetConnector,
+ &ConnectTcp,
+ &ConnectTcpAddress,
+};
+
+} // namespace
+
+PPB_Flash_NetConnector_Impl::PPB_Flash_NetConnector_Impl(
+ PluginInstance* instance)
+ : Resource(instance) {
+}
+
+PPB_Flash_NetConnector_Impl::~PPB_Flash_NetConnector_Impl() {
+}
+
+// static
+const PPB_Flash_NetConnector* PPB_Flash_NetConnector_Impl::GetInterface() {
+ return &ppb_flash_netconnector;
+}
+
+PPB_Flash_NetConnector_Impl*
+ PPB_Flash_NetConnector_Impl::AsPPB_Flash_NetConnector_Impl() {
+ return this;
+}
+
+int32_t PPB_Flash_NetConnector_Impl::ConnectTcp(
+ const char* host,
+ uint16_t port,
+ PP_FileHandle* socket_out,
+ PP_Flash_NetAddress* local_addr_out,
+ PP_Flash_NetAddress* remote_addr_out,
+ PP_CompletionCallback callback) {
+ // |socket_out| is not optional.
+ if (!socket_out)
+ return PP_ERROR_BADARGUMENT;
+
+ if (!callback.func) {
+ NOTIMPLEMENTED();
+ return PP_ERROR_BADARGUMENT;
+ }
+
+ if (callback_.get() && !callback_->completed())
+ return PP_ERROR_INPROGRESS;
+
+ PP_Resource resource_id = GetReferenceNoAddRef();
+ if (!resource_id) {
+ NOTREACHED();
+ return PP_ERROR_FAILED;
+ }
+
+ int32_t rv = instance()->delegate()->ConnectTcp(this, host, port);
+ if (rv == PP_ERROR_WOULDBLOCK) {
+ // Record callback and output buffers.
+ callback_ = new TrackedCompletionCallback(
+ instance()->module()->GetCallbackTracker(), resource_id, callback);
+ socket_out_ = socket_out;
+ local_addr_out_ = local_addr_out;
+ remote_addr_out_ = remote_addr_out;
+ } else {
+ // This should never be completed synchronously successfully.
+ DCHECK_NE(rv, PP_OK);
+ }
+ return rv;
+}
+
+int32_t PPB_Flash_NetConnector_Impl::ConnectTcpAddress(
+ const PP_Flash_NetAddress* addr,
+ PP_FileHandle* socket_out,
+ PP_Flash_NetAddress* local_addr_out,
+ PP_Flash_NetAddress* remote_addr_out,
+ PP_CompletionCallback callback) {
+ // |socket_out| is not optional.
+ if (!socket_out)
+ return PP_ERROR_BADARGUMENT;
+
+ if (!callback.func) {
+ NOTIMPLEMENTED();
+ return PP_ERROR_BADARGUMENT;
+ }
+
+ if (callback_.get() && !callback_->completed())
+ return PP_ERROR_INPROGRESS;
+
+ PP_Resource resource_id = GetReferenceNoAddRef();
+ if (!resource_id) {
+ NOTREACHED();
+ return PP_ERROR_FAILED;
+ }
+
+ int32_t rv = instance()->delegate()->ConnectTcpAddress(this, addr);
+ if (rv == PP_ERROR_WOULDBLOCK) {
+ // Record callback and output buffers.
+ callback_ = new TrackedCompletionCallback(
+ instance()->module()->GetCallbackTracker(), resource_id, callback);
+ socket_out_ = socket_out;
+ local_addr_out_ = local_addr_out;
+ remote_addr_out_ = remote_addr_out;
+ } else {
+ // This should never be completed synchronously successfully.
+ DCHECK_NE(rv, PP_OK);
+ }
+ return rv;
+}
+
+void PPB_Flash_NetConnector_Impl::CompleteConnectTcp(
+ PP_FileHandle socket,
+ const PP_Flash_NetAddress& local_addr,
+ const PP_Flash_NetAddress& remote_addr) {
+ int32_t rv = PP_ERROR_ABORTED;
+ if (!callback_->aborted()) {
+ CHECK(!callback_->completed());
+
+ // Write output data.
+ *socket_out_ = socket;
+ if (socket != PP_kInvalidFileHandle) {
+ if (local_addr_out_)
+ *local_addr_out_ = local_addr;
+ if (remote_addr_out_)
+ *remote_addr_out_ = remote_addr;
+ rv = PP_OK;
+ } else {
+ rv = PP_ERROR_FAILED;
+ }
+ }
+
+ // Theoretically, the plugin should be allowed to try another |ConnectTcp()|
+ // from the callback.
+ scoped_refptr<TrackedCompletionCallback> callback;
+ callback.swap(callback_);
+ // Wipe everything else out for safety.
+ socket_out_ = NULL;
+ local_addr_out_ = NULL;
+ remote_addr_out_ = NULL;
+
+ callback->Run(rv); // Will complete abortively if necessary.
+}
+
+} // namespace ppapi
+} // namespace webkit
+
diff --git a/webkit/plugins/ppapi/ppb_flash_net_connector_impl.h b/webkit/plugins/ppapi/ppb_flash_net_connector_impl.h
new file mode 100644
index 0000000..2d1d7dc
--- /dev/null
+++ b/webkit/plugins/ppapi/ppb_flash_net_connector_impl.h
@@ -0,0 +1,61 @@
+// Copyright (c) 2011 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 WEBKIT_PLUGINS_PPAPI_PPB_FLASH_NET_CONNECTOR_IMPL_H_
+#define WEBKIT_PLUGINS_PPAPI_PPB_FLASH_NET_CONNECTOR_IMPL_H_
+
+#include "base/basictypes.h"
+#include "base/ref_counted.h"
+#include "ppapi/c/private/ppb_flash_net_connector.h"
+#include "webkit/plugins/ppapi/callbacks.h"
+#include "webkit/plugins/ppapi/resource.h"
+
+namespace webkit {
+namespace ppapi {
+
+class PPB_Flash_NetConnector_Impl : public Resource {
+ public:
+ explicit PPB_Flash_NetConnector_Impl(PluginInstance* instance);
+ virtual ~PPB_Flash_NetConnector_Impl();
+
+ static const PPB_Flash_NetConnector* GetInterface();
+
+ // Resource override.
+ virtual PPB_Flash_NetConnector_Impl* AsPPB_Flash_NetConnector_Impl();
+
+ // PPB_Flash_NetConnector implementation.
+ int32_t ConnectTcp(const char* host,
+ uint16_t port,
+ PP_FileHandle* socket_out,
+ PP_Flash_NetAddress* local_addr_out,
+ PP_Flash_NetAddress* remote_addr_out,
+ PP_CompletionCallback callback);
+ int32_t ConnectTcpAddress(const PP_Flash_NetAddress* addr,
+ PP_FileHandle* socket_out,
+ PP_Flash_NetAddress* local_addr_out,
+ PP_Flash_NetAddress* remote_addr_out,
+ PP_CompletionCallback callback);
+
+ // Called to complete |ConnectTcp()| and |ConnectTcpAddress()|.
+ void CompleteConnectTcp(PP_FileHandle socket,
+ const PP_Flash_NetAddress& local_addr,
+ const PP_Flash_NetAddress& remote_addr);
+
+ private:
+ // Any pending callback (for |ConnectTcp()| or |ConnectTcpAddress()|).
+ scoped_refptr<TrackedCompletionCallback> callback_;
+
+ // Output buffers to be filled in when the callback is completed successfully
+ // (|{local,remote}_addr_out| are optional and may be null).
+ PP_FileHandle* socket_out_;
+ PP_Flash_NetAddress* local_addr_out_;
+ PP_Flash_NetAddress* remote_addr_out_;
+
+ DISALLOW_COPY_AND_ASSIGN(PPB_Flash_NetConnector_Impl);
+};
+
+} // namespace ppapi
+} // namespace webkit
+
+#endif // WEBKIT_PLUGINS_PPAPI_PPB_FLASH_NET_CONNECTOR_IMPL_H_