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

Unified Diff: ppapi/proxy/resource_reply_thread_registrar.cc

Issue 563073002: Pepper UDP socket: buffer received packets in the plugin process to improve performance. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: ppapi/proxy/resource_reply_thread_registrar.cc
diff --git a/ppapi/proxy/resource_reply_thread_registrar.cc b/ppapi/proxy/resource_reply_thread_registrar.cc
index 13329872aa17c037133ecfd85422e7eca33bc7c2..7e294fe835885ad4ea0596da2e00c5f09c536164 100644
--- a/ppapi/proxy/resource_reply_thread_registrar.cc
+++ b/ppapi/proxy/resource_reply_thread_registrar.cc
@@ -6,6 +6,8 @@
#include "base/logging.h"
#include "base/message_loop/message_loop_proxy.h"
+#include "ipc/ipc_message.h"
+#include "ppapi/proxy/resource_message_params.h"
#include "ppapi/shared_impl/proxy_lock.h"
#include "ppapi/shared_impl/tracked_callback.h"
@@ -13,8 +15,8 @@ namespace ppapi {
namespace proxy {
ResourceReplyThreadRegistrar::ResourceReplyThreadRegistrar(
- scoped_refptr<base::MessageLoopProxy> default_thread)
- : default_thread_(default_thread) {
+ scoped_refptr<base::MessageLoopProxy> main_thread)
+ : main_thread_(main_thread) {
}
ResourceReplyThreadRegistrar::~ResourceReplyThreadRegistrar() {
@@ -26,7 +28,7 @@ void ResourceReplyThreadRegistrar::Register(
scoped_refptr<TrackedCallback> reply_thread_hint) {
ProxyLock::AssertAcquiredDebugOnly();
- // Use the default thread if |reply_thread_hint| is NULL or blocking.
+ // Use the main thread if |reply_thread_hint| is NULL or blocking.
if (!reply_thread_hint.get() || reply_thread_hint->is_blocking())
return;
@@ -36,35 +38,48 @@ void ResourceReplyThreadRegistrar::Register(
{
base::AutoLock auto_lock(lock_);
- if (reply_thread.get() == default_thread_.get())
+ if (reply_thread.get() == main_thread_.get())
return;
- map_[resource][sequence_number] = reply_thread;
+ map_[resource].thread_map[sequence_number] = reply_thread;
}
}
+void ResourceReplyThreadRegistrar::HandleOnIOThread(
+ PP_Resource resource, uint32 nested_msg_type) {
+ base::AutoLock auto_lock(lock_);
+ map_[resource].io_thread_message_types.insert(nested_msg_type);
+}
+
void ResourceReplyThreadRegistrar::Unregister(PP_Resource resource) {
base::AutoLock auto_lock(lock_);
map_.erase(resource);
}
scoped_refptr<base::MessageLoopProxy>
-ResourceReplyThreadRegistrar::GetTargetThreadAndUnregister(
- PP_Resource resource,
- int32_t sequence_number) {
+ResourceReplyThreadRegistrar::GetTargetThread(
+ const ResourceMessageReplyParams& reply_params,
+ const IPC::Message& nested_msg) {
base::AutoLock auto_lock(lock_);
- ResourceMap::iterator resource_iter = map_.find(resource);
+ ResourceMap::iterator resource_iter = map_.find(reply_params.pp_resource());
if (resource_iter == map_.end())
- return default_thread_;
+ return main_thread_;
- SequenceNumberMap::iterator sequence_number_iter =
- resource_iter->second.find(sequence_number);
- if (sequence_number_iter == resource_iter->second.end())
- return default_thread_;
+ ResourceInfo& info = resource_iter->second;
+ SequenceThreadMap::iterator sequence_thread_iter =
+ info.thread_map.find(reply_params.sequence());
+ if (sequence_thread_iter != info.thread_map.end()) {
+ scoped_refptr<base::MessageLoopProxy> target = sequence_thread_iter->second;
+ info.thread_map.erase(sequence_thread_iter);
+ return target;
+ }
+
+ if (info.io_thread_message_types.find(nested_msg.type()) !=
+ info.io_thread_message_types.end()) {
+ return scoped_refptr<base::MessageLoopProxy>();
+ }
- scoped_refptr<base::MessageLoopProxy> target = sequence_number_iter->second;
- resource_iter->second.erase(sequence_number_iter);
- return target;
+ return main_thread_;
}
} // namespace proxy

Powered by Google App Engine
This is Rietveld 408576698