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_message_loop_proxy.h" | 5 #include "ppapi/proxy/ppb_message_loop_proxy.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "ppapi/c/dev/ppb_message_loop_dev.h" | 12 #include "ppapi/c/dev/ppb_message_loop_dev.h" |
13 #include "ppapi/c/pp_errors.h" | 13 #include "ppapi/c/pp_errors.h" |
14 #include "ppapi/proxy/plugin_dispatcher.h" | 14 #include "ppapi/proxy/plugin_dispatcher.h" |
15 #include "ppapi/proxy/plugin_globals.h" | 15 #include "ppapi/proxy/plugin_globals.h" |
| 16 #include "ppapi/shared_impl/proxy_lock.h" |
16 #include "ppapi/shared_impl/resource.h" | 17 #include "ppapi/shared_impl/resource.h" |
17 #include "ppapi/thunk/enter.h" | 18 #include "ppapi/thunk/enter.h" |
18 #include "ppapi/thunk/ppb_message_loop_api.h" | 19 #include "ppapi/thunk/ppb_message_loop_api.h" |
19 | 20 |
20 using ppapi::thunk::PPB_MessageLoop_API; | 21 using ppapi::thunk::PPB_MessageLoop_API; |
21 | 22 |
22 namespace ppapi { | 23 namespace ppapi { |
23 namespace proxy { | 24 namespace proxy { |
24 | 25 |
25 namespace { | 26 namespace { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 return PP_OK; | 134 return PP_OK; |
134 } | 135 } |
135 | 136 |
136 int32_t MessageLoopResource::Run() { | 137 int32_t MessageLoopResource::Run() { |
137 if (!IsCurrent()) | 138 if (!IsCurrent()) |
138 return PP_ERROR_WRONG_THREAD; | 139 return PP_ERROR_WRONG_THREAD; |
139 // TODO(brettw) prevent this from happening on the main thread & return | 140 // TODO(brettw) prevent this from happening on the main thread & return |
140 // PP_ERROR_BLOCKS_MAIN_THREAD. Maybe have a special constructor for that | 141 // PP_ERROR_BLOCKS_MAIN_THREAD. Maybe have a special constructor for that |
141 // one? | 142 // one? |
142 | 143 |
143 // TODO(brettw) figure out how to release the lock. Can't run the message | |
144 // loop while holding the lock. | |
145 nested_invocations_++; | 144 nested_invocations_++; |
146 loop_->Run(); | 145 CallWhileUnlocked(base::Bind(&MessageLoop::Run, |
| 146 base::Unretained(loop_.get()))); |
147 nested_invocations_--; | 147 nested_invocations_--; |
148 | 148 |
149 if (should_destroy_ && nested_invocations_ == 0) { | 149 if (should_destroy_ && nested_invocations_ == 0) { |
150 loop_.reset(); | 150 loop_.reset(); |
151 destroyed_ = true; | 151 destroyed_ = true; |
152 } | 152 } |
153 return PP_OK; | 153 return PP_OK; |
154 } | 154 } |
155 | 155 |
156 int32_t MessageLoopResource::PostWork(PP_CompletionCallback callback, | 156 int32_t MessageLoopResource::PostWork(PP_CompletionCallback callback, |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 PPB_MessageLoop_Proxy::~PPB_MessageLoop_Proxy() { | 290 PPB_MessageLoop_Proxy::~PPB_MessageLoop_Proxy() { |
291 } | 291 } |
292 | 292 |
293 // static | 293 // static |
294 const PPB_MessageLoop_Dev_0_1* PPB_MessageLoop_Proxy::GetInterface() { | 294 const PPB_MessageLoop_Dev_0_1* PPB_MessageLoop_Proxy::GetInterface() { |
295 return &ppb_message_loop_interface; | 295 return &ppb_message_loop_interface; |
296 } | 296 } |
297 | 297 |
298 } // namespace proxy | 298 } // namespace proxy |
299 } // namespace ppapi | 299 } // namespace ppapi |
OLD | NEW |