Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: webkit/plugins/ppapi/ppb_flash_net_connector_impl.cc

Issue 7669055: Remove webkit::ppapi::Resource. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nulls auditeed Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/plugins/ppapi/ppb_flash_net_connector_impl.h" 5 #include "webkit/plugins/ppapi/ppb_flash_net_connector_impl.h"
6 6
7 #include "ppapi/c/pp_completion_callback.h" 7 #include "ppapi/c/pp_completion_callback.h"
8 #include "ppapi/c/private/ppb_flash_net_connector.h" 8 #include "ppapi/c/private/ppb_flash_net_connector.h"
9 #include "webkit/plugins/ppapi/common.h" 9 #include "webkit/plugins/ppapi/common.h"
10 #include "webkit/plugins/ppapi/plugin_delegate.h" 10 #include "webkit/plugins/ppapi/plugin_delegate.h"
11 #include "webkit/plugins/ppapi/plugin_module.h" 11 #include "webkit/plugins/ppapi/plugin_module.h"
12 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 12 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
13 #include "webkit/plugins/ppapi/resource_helper.h"
13 14
14 using ::ppapi::thunk::PPB_Flash_NetConnector_API; 15 using ::ppapi::thunk::PPB_Flash_NetConnector_API;
15 16
16 namespace webkit { 17 namespace webkit {
17 namespace ppapi { 18 namespace ppapi {
18 19
19 PPB_Flash_NetConnector_Impl::PPB_Flash_NetConnector_Impl( 20 PPB_Flash_NetConnector_Impl::PPB_Flash_NetConnector_Impl(PP_Instance instance)
20 PluginInstance* instance)
21 : Resource(instance) { 21 : Resource(instance) {
22 } 22 }
23 23
24 PPB_Flash_NetConnector_Impl::~PPB_Flash_NetConnector_Impl() { 24 PPB_Flash_NetConnector_Impl::~PPB_Flash_NetConnector_Impl() {
25 } 25 }
26 26
27 PPB_Flash_NetConnector_API* 27 PPB_Flash_NetConnector_API*
28 PPB_Flash_NetConnector_Impl::AsPPB_Flash_NetConnector_API() { 28 PPB_Flash_NetConnector_Impl::AsPPB_Flash_NetConnector_API() {
29 return this; 29 return this;
30 } 30 }
(...skipping 10 matching lines...) Expand all
41 return PP_ERROR_BADARGUMENT; 41 return PP_ERROR_BADARGUMENT;
42 42
43 if (!callback.func) { 43 if (!callback.func) {
44 NOTIMPLEMENTED(); 44 NOTIMPLEMENTED();
45 return PP_ERROR_BADARGUMENT; 45 return PP_ERROR_BADARGUMENT;
46 } 46 }
47 47
48 if (callback_.get() && !callback_->completed()) 48 if (callback_.get() && !callback_->completed())
49 return PP_ERROR_INPROGRESS; 49 return PP_ERROR_INPROGRESS;
50 50
51 int32_t rv = instance()->delegate()->ConnectTcp(this, host, port); 51 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
52 if (!plugin_instance)
53 return false;
54 int32_t rv = plugin_instance->delegate()->ConnectTcp(this, host, port);
52 if (rv == PP_OK_COMPLETIONPENDING) { 55 if (rv == PP_OK_COMPLETIONPENDING) {
53 // Record callback and output buffers. 56 // Record callback and output buffers.
54 callback_ = new TrackedCompletionCallback( 57 callback_ = new TrackedCompletionCallback(
55 instance()->module()->GetCallbackTracker(), pp_resource(), callback); 58 plugin_instance->module()->GetCallbackTracker(),
59 pp_resource(), callback);
56 socket_out_ = socket_out; 60 socket_out_ = socket_out;
57 local_addr_out_ = local_addr_out; 61 local_addr_out_ = local_addr_out;
58 remote_addr_out_ = remote_addr_out; 62 remote_addr_out_ = remote_addr_out;
59 } else { 63 } else {
60 // This should never be completed synchronously successfully. 64 // This should never be completed synchronously successfully.
61 DCHECK_NE(rv, PP_OK); 65 DCHECK_NE(rv, PP_OK);
62 } 66 }
63 return rv; 67 return rv;
64 } 68 }
65 69
66 int32_t PPB_Flash_NetConnector_Impl::ConnectTcpAddress( 70 int32_t PPB_Flash_NetConnector_Impl::ConnectTcpAddress(
67 const PP_Flash_NetAddress* addr, 71 const PP_Flash_NetAddress* addr,
68 PP_FileHandle* socket_out, 72 PP_FileHandle* socket_out,
69 PP_Flash_NetAddress* local_addr_out, 73 PP_Flash_NetAddress* local_addr_out,
70 PP_Flash_NetAddress* remote_addr_out, 74 PP_Flash_NetAddress* remote_addr_out,
71 PP_CompletionCallback callback) { 75 PP_CompletionCallback callback) {
72 // |socket_out| is not optional. 76 // |socket_out| is not optional.
73 if (!socket_out) 77 if (!socket_out)
74 return PP_ERROR_BADARGUMENT; 78 return PP_ERROR_BADARGUMENT;
75 79
76 if (!callback.func) { 80 if (!callback.func) {
77 NOTIMPLEMENTED(); 81 NOTIMPLEMENTED();
78 return PP_ERROR_BADARGUMENT; 82 return PP_ERROR_BADARGUMENT;
79 } 83 }
80 84
81 if (callback_.get() && !callback_->completed()) 85 if (callback_.get() && !callback_->completed())
82 return PP_ERROR_INPROGRESS; 86 return PP_ERROR_INPROGRESS;
83 87
84 int32_t rv = instance()->delegate()->ConnectTcpAddress(this, addr); 88 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
89 if (!plugin_instance)
90 return false;
91 int32_t rv = plugin_instance->delegate()->ConnectTcpAddress(this, addr);
85 if (rv == PP_OK_COMPLETIONPENDING) { 92 if (rv == PP_OK_COMPLETIONPENDING) {
86 // Record callback and output buffers. 93 // Record callback and output buffers.
87 callback_ = new TrackedCompletionCallback( 94 callback_ = new TrackedCompletionCallback(
88 instance()->module()->GetCallbackTracker(), pp_resource(), callback); 95 plugin_instance->module()->GetCallbackTracker(),
96 pp_resource(), callback);
89 socket_out_ = socket_out; 97 socket_out_ = socket_out;
90 local_addr_out_ = local_addr_out; 98 local_addr_out_ = local_addr_out;
91 remote_addr_out_ = remote_addr_out; 99 remote_addr_out_ = remote_addr_out;
92 } else { 100 } else {
93 // This should never be completed synchronously successfully. 101 // This should never be completed synchronously successfully.
94 DCHECK_NE(rv, PP_OK); 102 DCHECK_NE(rv, PP_OK);
95 } 103 }
96 return rv; 104 return rv;
97 } 105 }
98 106
(...skipping 26 matching lines...) Expand all
125 socket_out_ = NULL; 133 socket_out_ = NULL;
126 local_addr_out_ = NULL; 134 local_addr_out_ = NULL;
127 remote_addr_out_ = NULL; 135 remote_addr_out_ = NULL;
128 136
129 callback->Run(rv); // Will complete abortively if necessary. 137 callback->Run(rv); // Will complete abortively if necessary.
130 } 138 }
131 139
132 } // namespace ppapi 140 } // namespace ppapi
133 } // namespace webkit 141 } // namespace webkit
134 142
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppb_flash_net_connector_impl.h ('k') | webkit/plugins/ppapi/ppb_font_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698