| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/nacl_irt/ppapi_dispatcher.h" | 5 #include "ppapi/nacl_irt/ppapi_dispatcher.h" |
| 6 | 6 |
| 7 #include <stddef.h> |
| 8 |
| 7 #include <map> | 9 #include <map> |
| 8 #include <set> | 10 #include <set> |
| 9 | 11 |
| 10 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 11 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 12 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
| 13 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
| 14 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 15 #include "components/tracing/child_trace_message_filter.h" | 17 #include "components/tracing/child_trace_message_filter.h" |
| 16 #include "ipc/ipc_channel_handle.h" | 18 #include "ipc/ipc_channel_handle.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 base::SharedMemoryHandle PpapiDispatcher::ShareSharedMemoryHandleWithRemote( | 77 base::SharedMemoryHandle PpapiDispatcher::ShareSharedMemoryHandleWithRemote( |
| 76 const base::SharedMemoryHandle& handle, | 78 const base::SharedMemoryHandle& handle, |
| 77 base::ProcessId remote_pid) { | 79 base::ProcessId remote_pid) { |
| 78 return base::SharedMemory::NULLHandle(); | 80 return base::SharedMemory::NULLHandle(); |
| 79 } | 81 } |
| 80 | 82 |
| 81 std::set<PP_Instance>* PpapiDispatcher::GetGloballySeenInstanceIDSet() { | 83 std::set<PP_Instance>* PpapiDispatcher::GetGloballySeenInstanceIDSet() { |
| 82 return &instances_; | 84 return &instances_; |
| 83 } | 85 } |
| 84 | 86 |
| 85 uint32 PpapiDispatcher::Register(proxy::PluginDispatcher* plugin_dispatcher) { | 87 uint32_t PpapiDispatcher::Register(proxy::PluginDispatcher* plugin_dispatcher) { |
| 86 if (!plugin_dispatcher || | 88 if (!plugin_dispatcher || |
| 87 plugin_dispatchers_.size() >= std::numeric_limits<uint32>::max()) { | 89 plugin_dispatchers_.size() >= std::numeric_limits<uint32_t>::max()) { |
| 88 return 0; | 90 return 0; |
| 89 } | 91 } |
| 90 | 92 |
| 91 uint32 id = 0; | 93 uint32_t id = 0; |
| 92 do { | 94 do { |
| 93 // Although it is unlikely, make sure that we won't cause any trouble | 95 // Although it is unlikely, make sure that we won't cause any trouble |
| 94 // when the counter overflows. | 96 // when the counter overflows. |
| 95 id = next_plugin_dispatcher_id_++; | 97 id = next_plugin_dispatcher_id_++; |
| 96 } while (id == 0 || | 98 } while (id == 0 || |
| 97 plugin_dispatchers_.find(id) != plugin_dispatchers_.end()); | 99 plugin_dispatchers_.find(id) != plugin_dispatchers_.end()); |
| 98 plugin_dispatchers_[id] = plugin_dispatcher; | 100 plugin_dispatchers_[id] = plugin_dispatcher; |
| 99 return id; | 101 return id; |
| 100 } | 102 } |
| 101 | 103 |
| 102 void PpapiDispatcher::Unregister(uint32 plugin_dispatcher_id) { | 104 void PpapiDispatcher::Unregister(uint32_t plugin_dispatcher_id) { |
| 103 plugin_dispatchers_.erase(plugin_dispatcher_id); | 105 plugin_dispatchers_.erase(plugin_dispatcher_id); |
| 104 } | 106 } |
| 105 | 107 |
| 106 IPC::Sender* PpapiDispatcher::GetBrowserSender() { | 108 IPC::Sender* PpapiDispatcher::GetBrowserSender() { |
| 107 return this; | 109 return this; |
| 108 } | 110 } |
| 109 | 111 |
| 110 std::string PpapiDispatcher::GetUILanguage() { | 112 std::string PpapiDispatcher::GetUILanguage() { |
| 111 NOTIMPLEMENTED(); | 113 NOTIMPLEMENTED(); |
| 112 return std::string(); | 114 return std::string(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 // Notify the renderer process, if necessary. | 198 // Notify the renderer process, if necessary. |
| 197 ManifestService* manifest_service = GetManifestService(); | 199 ManifestService* manifest_service = GetManifestService(); |
| 198 if (manifest_service) | 200 if (manifest_service) |
| 199 manifest_service->StartupInitializationComplete(); | 201 manifest_service->StartupInitializationComplete(); |
| 200 } | 202 } |
| 201 | 203 |
| 202 void PpapiDispatcher::OnPluginDispatcherMessageReceived( | 204 void PpapiDispatcher::OnPluginDispatcherMessageReceived( |
| 203 const IPC::Message& msg) { | 205 const IPC::Message& msg) { |
| 204 // The first parameter should be a plugin dispatcher ID. | 206 // The first parameter should be a plugin dispatcher ID. |
| 205 base::PickleIterator iter(msg); | 207 base::PickleIterator iter(msg); |
| 206 uint32 id = 0; | 208 uint32_t id = 0; |
| 207 if (!iter.ReadUInt32(&id)) { | 209 if (!iter.ReadUInt32(&id)) { |
| 208 NOTREACHED(); | 210 NOTREACHED(); |
| 209 return; | 211 return; |
| 210 } | 212 } |
| 211 std::map<uint32, proxy::PluginDispatcher*>::iterator dispatcher = | 213 std::map<uint32_t, proxy::PluginDispatcher*>::iterator dispatcher = |
| 212 plugin_dispatchers_.find(id); | 214 plugin_dispatchers_.find(id); |
| 213 if (dispatcher != plugin_dispatchers_.end()) | 215 if (dispatcher != plugin_dispatchers_.end()) |
| 214 dispatcher->second->OnMessageReceived(msg); | 216 dispatcher->second->OnMessageReceived(msg); |
| 215 } | 217 } |
| 216 | 218 |
| 217 } // namespace ppapi | 219 } // namespace ppapi |
| OLD | NEW |