OLD | NEW |
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/ppb_instance_proxy.h" | 5 #include "ppapi/proxy/ppb_instance_proxy.h" |
6 | 6 |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
10 #include "ppapi/c/pp_time.h" | 10 #include "ppapi/c/pp_time.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 namespace ppapi { | 55 namespace ppapi { |
56 namespace proxy { | 56 namespace proxy { |
57 | 57 |
58 namespace { | 58 namespace { |
59 | 59 |
60 const char kSerializationError[] = "Failed to convert a PostMessage " | 60 const char kSerializationError[] = "Failed to convert a PostMessage " |
61 "argument from a PP_Var to a Javascript value. It may have cycles or be of " | 61 "argument from a PP_Var to a Javascript value. It may have cycles or be of " |
62 "an unsupported type."; | 62 "an unsupported type."; |
63 | 63 |
64 InterfaceProxy* CreateInstanceProxy(Dispatcher* dispatcher) { | |
65 return new PPB_Instance_Proxy(dispatcher); | |
66 } | |
67 | |
68 void RequestSurroundingText(PP_Instance instance) { | 64 void RequestSurroundingText(PP_Instance instance) { |
69 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 65 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
70 if (!dispatcher) | 66 if (!dispatcher) |
71 return; // Instance has gone away while message was pending. | 67 return; // Instance has gone away while message was pending. |
72 | 68 |
73 InstanceData* data = dispatcher->GetInstanceData(instance); | 69 InstanceData* data = dispatcher->GetInstanceData(instance); |
74 DCHECK(data); // Should have it, since we still have a dispatcher. | 70 DCHECK(data); // Should have it, since we still have a dispatcher. |
75 data->is_request_surrounding_text_pending = false; | 71 data->is_request_surrounding_text_pending = false; |
76 if (!data->should_do_request_surrounding_text) | 72 if (!data->should_do_request_surrounding_text) |
77 return; | 73 return; |
(...skipping 11 matching lines...) Expand all Loading... |
89 } // namespace | 85 } // namespace |
90 | 86 |
91 PPB_Instance_Proxy::PPB_Instance_Proxy(Dispatcher* dispatcher) | 87 PPB_Instance_Proxy::PPB_Instance_Proxy(Dispatcher* dispatcher) |
92 : InterfaceProxy(dispatcher), | 88 : InterfaceProxy(dispatcher), |
93 callback_factory_(this) { | 89 callback_factory_(this) { |
94 } | 90 } |
95 | 91 |
96 PPB_Instance_Proxy::~PPB_Instance_Proxy() { | 92 PPB_Instance_Proxy::~PPB_Instance_Proxy() { |
97 } | 93 } |
98 | 94 |
99 // static | |
100 const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfoPrivate() { | |
101 static const Info info = { | |
102 ppapi::thunk::GetPPB_Instance_Private_0_1_Thunk(), | |
103 PPB_INSTANCE_PRIVATE_INTERFACE_0_1, | |
104 API_ID_NONE, // 1_0 is the canonical one. | |
105 false, | |
106 &CreateInstanceProxy, | |
107 }; | |
108 return &info; | |
109 } | |
110 | |
111 bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) { | 95 bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) { |
112 // Prevent the dispatcher from going away during a call to ExecuteScript. | 96 // Prevent the dispatcher from going away during a call to ExecuteScript. |
113 // This must happen OUTSIDE of ExecuteScript since the SerializedVars use | 97 // This must happen OUTSIDE of ExecuteScript since the SerializedVars use |
114 // the dispatcher upon return of the function (converting the | 98 // the dispatcher upon return of the function (converting the |
115 // SerializedVarReturnValue/OutParam to a SerializedVar in the destructor). | 99 // SerializedVarReturnValue/OutParam to a SerializedVar in the destructor). |
116 #if !defined(OS_NACL) | 100 #if !defined(OS_NACL) |
117 ScopedModuleReference death_grip(dispatcher()); | 101 ScopedModuleReference death_grip(dispatcher()); |
118 #endif | 102 #endif |
119 | 103 |
120 bool handled = true; | 104 bool handled = true; |
(...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1281 PP_Instance instance) { | 1265 PP_Instance instance) { |
1282 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> | 1266 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> |
1283 GetInstanceData(instance); | 1267 GetInstanceData(instance); |
1284 if (!data) | 1268 if (!data) |
1285 return; // Instance was probably deleted. | 1269 return; // Instance was probably deleted. |
1286 data->should_do_request_surrounding_text = false; | 1270 data->should_do_request_surrounding_text = false; |
1287 } | 1271 } |
1288 | 1272 |
1289 } // namespace proxy | 1273 } // namespace proxy |
1290 } // namespace ppapi | 1274 } // namespace ppapi |
OLD | NEW |