Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/location.h" | |
| 14 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
| 15 #include "ppapi/c/pp_errors.h" | 14 #include "ppapi/c/pp_errors.h" |
| 16 #include "ppapi/c/ppb_message_loop.h" | 15 #include "ppapi/c/ppb_message_loop.h" |
| 17 #include "ppapi/proxy/plugin_dispatcher.h" | 16 #include "ppapi/proxy/plugin_dispatcher.h" |
| 18 #include "ppapi/proxy/plugin_globals.h" | 17 #include "ppapi/proxy/plugin_globals.h" |
| 19 #include "ppapi/shared_impl/proxy_lock.h" | 18 #include "ppapi/shared_impl/proxy_lock.h" |
| 20 #include "ppapi/thunk/enter.h" | 19 #include "ppapi/thunk/enter.h" |
| 21 | 20 |
| 22 using ppapi::thunk::PPB_MessageLoop_API; | 21 using ppapi::thunk::PPB_MessageLoop_API; |
| 23 | 22 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 | 101 |
| 103 return PP_OK; | 102 return PP_OK; |
| 104 } | 103 } |
| 105 | 104 |
| 106 int32_t MessageLoopResource::Run() { | 105 int32_t MessageLoopResource::Run() { |
| 107 if (!IsCurrent()) | 106 if (!IsCurrent()) |
| 108 return PP_ERROR_WRONG_THREAD; | 107 return PP_ERROR_WRONG_THREAD; |
| 109 if (is_main_thread_loop_) | 108 if (is_main_thread_loop_) |
| 110 return PP_ERROR_INPROGRESS; | 109 return PP_ERROR_INPROGRESS; |
| 111 | 110 |
| 111 base::RunLoop* previous_run_loop = run_loop_; | |
| 112 base::RunLoop run_loop; | |
| 113 run_loop_ = &run_loop; | |
| 114 | |
| 112 nested_invocations_++; | 115 nested_invocations_++; |
| 113 CallWhileUnlocked( | 116 CallWhileUnlocked( |
| 114 base::Bind(&base::MessageLoop::Run, base::Unretained(loop_.get()))); | 117 base::Bind(&base::RunLoop::Run, base::Unretained(run_loop_))); |
| 115 nested_invocations_--; | 118 nested_invocations_--; |
| 116 | 119 |
| 120 run_loop_ = previous_run_loop; | |
|
gab
2016/07/08 18:36:08
Why does |run_loop_| need to be a member if it's o
fdoray
2016/07/08 20:21:10
I planned to use run_loop_ to quit the messageloop
| |
| 121 | |
| 117 if (should_destroy_ && nested_invocations_ == 0) { | 122 if (should_destroy_ && nested_invocations_ == 0) { |
| 118 task_runner_ = NULL; | 123 task_runner_ = NULL; |
| 119 loop_.reset(); | 124 loop_.reset(); |
| 120 destroyed_ = true; | 125 destroyed_ = true; |
| 121 } | 126 } |
| 122 return PP_OK; | 127 return PP_OK; |
| 123 } | 128 } |
| 124 | 129 |
| 125 int32_t MessageLoopResource::PostWork(PP_CompletionCallback callback, | 130 int32_t MessageLoopResource::PostWork(PP_CompletionCallback callback, |
| 126 int64_t delay_ms) { | 131 int64_t delay_ms) { |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 277 PPB_MessageLoop_Proxy::~PPB_MessageLoop_Proxy() { | 282 PPB_MessageLoop_Proxy::~PPB_MessageLoop_Proxy() { |
| 278 } | 283 } |
| 279 | 284 |
| 280 // static | 285 // static |
| 281 const PPB_MessageLoop_1_0* PPB_MessageLoop_Proxy::GetInterface() { | 286 const PPB_MessageLoop_1_0* PPB_MessageLoop_Proxy::GetInterface() { |
| 282 return &ppb_message_loop_interface; | 287 return &ppb_message_loop_interface; |
| 283 } | 288 } |
| 284 | 289 |
| 285 } // namespace proxy | 290 } // namespace proxy |
| 286 } // namespace ppapi | 291 } // namespace ppapi |
| OLD | NEW |