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

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

Issue 46433002: Support using TrackedCallbacks as hints to determine the handling thread of resource reply messages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | « ppapi/proxy/plugin_resource.h ('k') | ppapi/proxy/ppb_message_loop_proxy.h » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/plugin_resource.h" 5 #include "ppapi/proxy/plugin_resource.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "ppapi/proxy/plugin_globals.h"
9 #include "ppapi/proxy/ppapi_messages.h" 10 #include "ppapi/proxy/ppapi_messages.h"
11 #include "ppapi/shared_impl/ppapi_globals.h"
10 12
11 namespace ppapi { 13 namespace ppapi {
12 namespace proxy { 14 namespace proxy {
13 15
14 PluginResource::PluginResource(Connection connection, PP_Instance instance) 16 PluginResource::PluginResource(Connection connection, PP_Instance instance)
15 : Resource(OBJECT_IS_PROXY, instance), 17 : Resource(OBJECT_IS_PROXY, instance),
16 connection_(connection), 18 connection_(connection),
17 next_sequence_number_(1), 19 next_sequence_number_(1),
18 sent_create_to_browser_(false), 20 sent_create_to_browser_(false),
19 sent_create_to_renderer_(false) { 21 sent_create_to_renderer_(false),
22 resource_reply_thread_registrar_(
23 PpapiGlobals::Get()->IsPluginGlobals() ?
24 PluginGlobals::Get()->resource_reply_thread_registrar() : NULL) {
20 } 25 }
21 26
22 PluginResource::~PluginResource() { 27 PluginResource::~PluginResource() {
23 if (sent_create_to_browser_) { 28 if (sent_create_to_browser_) {
24 connection_.browser_sender->Send( 29 connection_.browser_sender->Send(
25 new PpapiHostMsg_ResourceDestroyed(pp_resource())); 30 new PpapiHostMsg_ResourceDestroyed(pp_resource()));
26 } 31 }
27 if (sent_create_to_renderer_) { 32 if (sent_create_to_renderer_) {
28 connection_.renderer_sender->Send( 33 connection_.renderer_sender->Send(
29 new PpapiHostMsg_ResourceDestroyed(pp_resource())); 34 new PpapiHostMsg_ResourceDestroyed(pp_resource()));
30 } 35 }
36
37 if (resource_reply_thread_registrar_)
38 resource_reply_thread_registrar_->Unregister(pp_resource());
31 } 39 }
32 40
33 void PluginResource::OnReplyReceived( 41 void PluginResource::OnReplyReceived(
34 const proxy::ResourceMessageReplyParams& params, 42 const proxy::ResourceMessageReplyParams& params,
35 const IPC::Message& msg) { 43 const IPC::Message& msg) {
36 TRACE_EVENT2("ppapi proxy", "PluginResource::OnReplyReceived", 44 TRACE_EVENT2("ppapi proxy", "PluginResource::OnReplyReceived",
37 "Class", IPC_MESSAGE_ID_CLASS(msg.type()), 45 "Class", IPC_MESSAGE_ID_CLASS(msg.type()),
38 "Line", IPC_MESSAGE_ID_LINE(msg.type())); 46 "Line", IPC_MESSAGE_ID_LINE(msg.type()));
39 // Grab the callback for the reply sequence number and run it with |msg|. 47 // Grab the callback for the reply sequence number and run it with |msg|.
40 CallbackMap::iterator it = callbacks_.find(params.sequence()); 48 CallbackMap::iterator it = callbacks_.find(params.sequence());
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 int32_t ret = next_sequence_number_; 159 int32_t ret = next_sequence_number_;
152 if (next_sequence_number_ == std::numeric_limits<int32_t>::max()) 160 if (next_sequence_number_ == std::numeric_limits<int32_t>::max())
153 next_sequence_number_ = 1; // Skip 0 which is invalid. 161 next_sequence_number_ = 1; // Skip 0 which is invalid.
154 else 162 else
155 next_sequence_number_++; 163 next_sequence_number_++;
156 return ret; 164 return ret;
157 } 165 }
158 166
159 } // namespace proxy 167 } // namespace proxy
160 } // namespace ppapi 168 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/plugin_resource.h ('k') | ppapi/proxy/ppb_message_loop_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698