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

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

Issue 7608030: Convert the PluginResource to be refcounted. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: 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 "ppapi/proxy/ppb_flash_tcp_socket_proxy.h" 5 #include "ppapi/proxy/ppb_flash_tcp_socket_proxy.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstring> 8 #include <cstring>
9 #include <map> 9 #include <map>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/linked_ptr.h"
13 #include "base/message_loop.h" 12 #include "base/message_loop.h"
14 #include "base/scoped_ptr.h" 13 #include "base/scoped_ptr.h"
15 #include "base/task.h" 14 #include "base/task.h"
16 #include "ppapi/c/pp_errors.h" 15 #include "ppapi/c/pp_errors.h"
17 #include "ppapi/proxy/plugin_dispatcher.h" 16 #include "ppapi/proxy/plugin_dispatcher.h"
18 #include "ppapi/proxy/plugin_resource.h" 17 #include "ppapi/proxy/plugin_resource.h"
19 #include "ppapi/proxy/plugin_resource_tracker.h" 18 #include "ppapi/proxy/plugin_resource_tracker.h"
20 #include "ppapi/proxy/ppapi_messages.h" 19 #include "ppapi/proxy/ppapi_messages.h"
21 #include "ppapi/thunk/ppb_flash_tcp_socket_api.h" 20 #include "ppapi/thunk/ppb_flash_tcp_socket_api.h"
22 #include "ppapi/thunk/thunk.h" 21 #include "ppapi/thunk/thunk.h"
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 if (!dispatcher) 367 if (!dispatcher)
369 return 0; 368 return 0;
370 369
371 uint32 socket_id = 0; 370 uint32 socket_id = 0;
372 dispatcher->SendToBrowser(new PpapiHostMsg_PPBFlashTCPSocket_Create( 371 dispatcher->SendToBrowser(new PpapiHostMsg_PPBFlashTCPSocket_Create(
373 INTERFACE_ID_PPB_FLASH_TCPSOCKET, dispatcher->plugin_dispatcher_id(), 372 INTERFACE_ID_PPB_FLASH_TCPSOCKET, dispatcher->plugin_dispatcher_id(),
374 &socket_id)); 373 &socket_id));
375 if (socket_id == 0) 374 if (socket_id == 0)
376 return 0; 375 return 0;
377 376
378 linked_ptr<FlashTCPSocket> object(new FlashTCPSocket( 377 return PluginResourceTracker::GetInstance()->AddResource(
379 HostResource::MakeInstanceOnly(instance), socket_id)); 378 new FlashTCPSocket(HostResource::MakeInstanceOnly(instance), socket_id));
380 return PluginResourceTracker::GetInstance()->AddResource(object);
381 } 379 }
382 380
383 bool PPB_Flash_TCPSocket_Proxy::OnMessageReceived(const IPC::Message& msg) { 381 bool PPB_Flash_TCPSocket_Proxy::OnMessageReceived(const IPC::Message& msg) {
384 bool handled = true; 382 bool handled = true;
385 IPC_BEGIN_MESSAGE_MAP(PPB_Flash_TCPSocket_Proxy, msg) 383 IPC_BEGIN_MESSAGE_MAP(PPB_Flash_TCPSocket_Proxy, msg)
386 IPC_MESSAGE_HANDLER(PpapiMsg_PPBFlashTCPSocket_ConnectACK, OnMsgConnectACK) 384 IPC_MESSAGE_HANDLER(PpapiMsg_PPBFlashTCPSocket_ConnectACK, OnMsgConnectACK)
387 IPC_MESSAGE_HANDLER(PpapiMsg_PPBFlashTCPSocket_ReadACK, OnMsgReadACK) 385 IPC_MESSAGE_HANDLER(PpapiMsg_PPBFlashTCPSocket_ReadACK, OnMsgReadACK)
388 IPC_MESSAGE_HANDLER(PpapiMsg_PPBFlashTCPSocket_WriteACK, OnMsgWriteACK) 386 IPC_MESSAGE_HANDLER(PpapiMsg_PPBFlashTCPSocket_WriteACK, OnMsgWriteACK)
389 IPC_MESSAGE_UNHANDLED(handled = false) 387 IPC_MESSAGE_UNHANDLED(handled = false)
390 IPC_END_MESSAGE_MAP() 388 IPC_END_MESSAGE_MAP()
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 return; 428 return;
431 } 429 }
432 IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); 430 IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id);
433 if (iter == g_id_to_socket->end()) 431 if (iter == g_id_to_socket->end())
434 return; 432 return;
435 iter->second->OnWriteCompleted(succeeded, bytes_written); 433 iter->second->OnWriteCompleted(succeeded, bytes_written);
436 } 434 }
437 435
438 } // namespace proxy 436 } // namespace proxy
439 } // namespace pp 437 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698