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

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

Issue 7629017: Add a unified resource tracker shared between the proxy and the impl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments 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"
(...skipping 30 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 PP_Resource resource_id = GetReferenceNoAddRef();
52 if (!resource_id) {
53 NOTREACHED();
54 return PP_ERROR_FAILED;
55 }
56
57 int32_t rv = instance()->delegate()->ConnectTcp(this, host, port); 51 int32_t rv = instance()->delegate()->ConnectTcp(this, host, port);
58 if (rv == PP_OK_COMPLETIONPENDING) { 52 if (rv == PP_OK_COMPLETIONPENDING) {
59 // Record callback and output buffers. 53 // Record callback and output buffers.
60 callback_ = new TrackedCompletionCallback( 54 callback_ = new TrackedCompletionCallback(
61 instance()->module()->GetCallbackTracker(), resource_id, callback); 55 instance()->module()->GetCallbackTracker(), pp_resource(), callback);
62 socket_out_ = socket_out; 56 socket_out_ = socket_out;
63 local_addr_out_ = local_addr_out; 57 local_addr_out_ = local_addr_out;
64 remote_addr_out_ = remote_addr_out; 58 remote_addr_out_ = remote_addr_out;
65 } else { 59 } else {
66 // This should never be completed synchronously successfully. 60 // This should never be completed synchronously successfully.
67 DCHECK_NE(rv, PP_OK); 61 DCHECK_NE(rv, PP_OK);
68 } 62 }
69 return rv; 63 return rv;
70 } 64 }
71 65
72 int32_t PPB_Flash_NetConnector_Impl::ConnectTcpAddress( 66 int32_t PPB_Flash_NetConnector_Impl::ConnectTcpAddress(
73 const PP_Flash_NetAddress* addr, 67 const PP_Flash_NetAddress* addr,
74 PP_FileHandle* socket_out, 68 PP_FileHandle* socket_out,
75 PP_Flash_NetAddress* local_addr_out, 69 PP_Flash_NetAddress* local_addr_out,
76 PP_Flash_NetAddress* remote_addr_out, 70 PP_Flash_NetAddress* remote_addr_out,
77 PP_CompletionCallback callback) { 71 PP_CompletionCallback callback) {
78 // |socket_out| is not optional. 72 // |socket_out| is not optional.
79 if (!socket_out) 73 if (!socket_out)
80 return PP_ERROR_BADARGUMENT; 74 return PP_ERROR_BADARGUMENT;
81 75
82 if (!callback.func) { 76 if (!callback.func) {
83 NOTIMPLEMENTED(); 77 NOTIMPLEMENTED();
84 return PP_ERROR_BADARGUMENT; 78 return PP_ERROR_BADARGUMENT;
85 } 79 }
86 80
87 if (callback_.get() && !callback_->completed()) 81 if (callback_.get() && !callback_->completed())
88 return PP_ERROR_INPROGRESS; 82 return PP_ERROR_INPROGRESS;
89 83
90 PP_Resource resource_id = GetReferenceNoAddRef();
91 if (!resource_id) {
92 NOTREACHED();
93 return PP_ERROR_FAILED;
94 }
95
96 int32_t rv = instance()->delegate()->ConnectTcpAddress(this, addr); 84 int32_t rv = instance()->delegate()->ConnectTcpAddress(this, addr);
97 if (rv == PP_OK_COMPLETIONPENDING) { 85 if (rv == PP_OK_COMPLETIONPENDING) {
98 // Record callback and output buffers. 86 // Record callback and output buffers.
99 callback_ = new TrackedCompletionCallback( 87 callback_ = new TrackedCompletionCallback(
100 instance()->module()->GetCallbackTracker(), resource_id, callback); 88 instance()->module()->GetCallbackTracker(), pp_resource(), callback);
101 socket_out_ = socket_out; 89 socket_out_ = socket_out;
102 local_addr_out_ = local_addr_out; 90 local_addr_out_ = local_addr_out;
103 remote_addr_out_ = remote_addr_out; 91 remote_addr_out_ = remote_addr_out;
104 } else { 92 } else {
105 // This should never be completed synchronously successfully. 93 // This should never be completed synchronously successfully.
106 DCHECK_NE(rv, PP_OK); 94 DCHECK_NE(rv, PP_OK);
107 } 95 }
108 return rv; 96 return rv;
109 } 97 }
110 98
(...skipping 26 matching lines...) Expand all
137 socket_out_ = NULL; 125 socket_out_ = NULL;
138 local_addr_out_ = NULL; 126 local_addr_out_ = NULL;
139 remote_addr_out_ = NULL; 127 remote_addr_out_ = NULL;
140 128
141 callback->Run(rv); // Will complete abortively if necessary. 129 callback->Run(rv); // Will complete abortively if necessary.
142 } 130 }
143 131
144 } // namespace ppapi 132 } // namespace ppapi
145 } // namespace webkit 133 } // namespace webkit
146 134
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698