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

Side by Side Diff: ppapi/proxy/ppb_flash_net_connector_proxy.cc

Issue 7067014: Don't re-enter when destroying FlashNetConnector (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ppapi/proxy/ppb_flash_net_connector_proxy.h" 5 #include "ppapi/proxy/ppb_flash_net_connector_proxy.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ppapi/c/pp_errors.h" 9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/c/private/ppb_flash_net_connector.h" 10 #include "ppapi/c/private/ppb_flash_net_connector.h"
11 #include "ppapi/proxy/plugin_dispatcher.h" 11 #include "ppapi/proxy/plugin_dispatcher.h"
12 #include "ppapi/proxy/plugin_resource.h" 12 #include "ppapi/proxy/plugin_resource.h"
13 #include "ppapi/proxy/ppapi_messages.h" 13 #include "ppapi/proxy/ppapi_messages.h"
14 #include "ppapi/proxy/serialized_var.h" 14 #include "ppapi/proxy/serialized_var.h"
15 15
16 namespace pp { 16 namespace pp {
17 namespace proxy { 17 namespace proxy {
18 18
19 std::string NetAddressToString(const PP_Flash_NetAddress& addr) { 19 std::string NetAddressToString(const PP_Flash_NetAddress& addr) {
20 return std::string(addr.data, std::min(static_cast<size_t>(addr.size), 20 return std::string(addr.data, std::min(static_cast<size_t>(addr.size),
21 sizeof(addr.data))); 21 sizeof(addr.data)));
22 } 22 }
23 23
24 void StringToNetAddress(const std::string& str, PP_Flash_NetAddress* addr) { 24 void StringToNetAddress(const std::string& str, PP_Flash_NetAddress* addr) {
25 addr->size = std::min(str.size(), sizeof(addr->data)); 25 addr->size = std::min(str.size(), sizeof(addr->data));
26 memcpy(addr->data, str.data(), addr->size); 26 memcpy(addr->data, str.data(), addr->size);
27 } 27 }
28 28
29 class AbortCallbackTask : public Task {
30 public:
31 AbortCallbackTask(PP_CompletionCallback callback)
32 : callback_(callback) {}
33
34 virtual void Run() {
35 PP_RunCompletionCallback(&callback_, PP_ERROR_ABORTED);
36 }
37
38 private:
39 PP_CompletionCallback callback_;
40 };
41
29 class FlashNetConnector : public PluginResource { 42 class FlashNetConnector : public PluginResource {
30 public: 43 public:
31 FlashNetConnector(const HostResource& resource) 44 FlashNetConnector(const HostResource& resource)
32 : PluginResource(resource), 45 : PluginResource(resource),
33 callback_(PP_BlockUntilComplete()), 46 callback_(PP_BlockUntilComplete()),
34 local_addr_out_(NULL), 47 local_addr_out_(NULL),
35 remote_addr_out_(NULL) { 48 remote_addr_out_(NULL) {
36 } 49 }
37 ~FlashNetConnector() { 50 ~FlashNetConnector() {
38 if (callback_.func) 51 if (callback_.func)
39 PP_RunCompletionCallback(&callback_, PP_ERROR_ABORTED); 52 MessageLoop::current()->PostTask(FROM_HERE,
viettrungluu 2011/05/24 17:39:48 Nit: Our style rules apparently dictate braces for
53 new AbortCallbackTask(callback_));
40 } 54 }
41 55
42 // Resource overrides. 56 // Resource overrides.
43 virtual FlashNetConnector* AsFlashNetConnector() { 57 virtual FlashNetConnector* AsFlashNetConnector() {
44 return this; 58 return this;
45 } 59 }
46 60
47 bool HasCallback() const { 61 bool HasCallback() const {
48 return callback_.func != NULL; 62 return callback_.func != NULL;
49 } 63 }
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 } else { 332 } else {
319 dispatcher()->Send(new PpapiMsg_PPBFlashNetConnector_ConnectACK( 333 dispatcher()->Send(new PpapiMsg_PPBFlashNetConnector_ConnectACK(
320 INTERFACE_ID_PPB_FLASH_NETCONNECTOR, 334 INTERFACE_ID_PPB_FLASH_NETCONNECTOR,
321 info->resource, result, 335 info->resource, result,
322 IPC::InvalidPlatformFileForTransit(), std::string(), std::string())); 336 IPC::InvalidPlatformFileForTransit(), std::string(), std::string()));
323 } 337 }
324 } 338 }
325 339
326 } // namespace proxy 340 } // namespace proxy
327 } // namespace pp 341 } // namespace pp
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698