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 "content/renderer/pepper/ppb_flash_message_loop_impl.h" | 5 #include "content/renderer/pepper/ppb_flash_message_loop_impl.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 const RunFromHostProxyCallback& callback) { | 77 const RunFromHostProxyCallback& callback) { |
78 if (state_->run_called()) { | 78 if (state_->run_called()) { |
79 if (!callback.is_null()) | 79 if (!callback.is_null()) |
80 callback.Run(PP_ERROR_FAILED); | 80 callback.Run(PP_ERROR_FAILED); |
81 return PP_ERROR_FAILED; | 81 return PP_ERROR_FAILED; |
82 } | 82 } |
83 state_->set_run_called(); | 83 state_->set_run_called(); |
84 state_->set_run_callback(callback); | 84 state_->set_run_callback(callback); |
85 | 85 |
86 // It is possible that the PPB_Flash_MessageLoop_Impl object has been | 86 // It is possible that the PPB_Flash_MessageLoop_Impl object has been |
87 // destroyed when the nested message loop exits. | 87 // destroyed when the nested run loop exits. |
88 scoped_refptr<State> state_protector(state_); | 88 scoped_refptr<State> state_protector(state_); |
89 { | 89 { |
90 base::MessageLoop::ScopedNestableTaskAllower allow( | 90 base::MessageLoop::ScopedNestableTaskAllower allow( |
91 base::MessageLoop::current()); | 91 base::MessageLoop::current()); |
92 blink::WebView::WillEnterModalLoop(); | 92 blink::WebView::WillEnterModalLoop(); |
93 | 93 |
94 base::RunLoop().Run(); | 94 base::RunLoop().Run(); |
95 | 95 |
96 blink::WebView::DidExitModalLoop(); | 96 blink::WebView::DidExitModalLoop(); |
97 } | 97 } |
98 // Don't access data members of the class below. | 98 // Don't access data members of the class below. |
99 | 99 |
100 return state_protector->result(); | 100 return state_protector->result(); |
101 } | 101 } |
102 | 102 |
103 void PPB_Flash_MessageLoop_Impl::InternalQuit(int32_t result) { | 103 void PPB_Flash_MessageLoop_Impl::InternalQuit(int32_t result) { |
104 if (!state_->run_called() || state_->quit_called()) | 104 if (!state_->run_called() || state_->quit_called()) |
105 return; | 105 return; |
106 state_->set_quit_called(); | 106 state_->set_quit_called(); |
107 state_->set_result(result); | 107 state_->set_result(result); |
108 | 108 |
109 base::MessageLoop::current()->QuitNow(); | 109 base::MessageLoop::current()->QuitNow(); |
110 | 110 |
111 if (!state_->run_callback().is_null()) | 111 if (!state_->run_callback().is_null()) |
112 state_->run_callback().Run(result); | 112 state_->run_callback().Run(result); |
113 } | 113 } |
114 | 114 |
115 } // namespace content | 115 } // namespace content |
OLD | NEW |