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 "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
| 10 #include "third_party/WebKit/public/web/WebView.h" |
10 | 11 |
11 using ppapi::thunk::PPB_Flash_MessageLoop_API; | 12 using ppapi::thunk::PPB_Flash_MessageLoop_API; |
12 | 13 |
13 namespace content { | 14 namespace content { |
14 | 15 |
15 class PPB_Flash_MessageLoop_Impl::State | 16 class PPB_Flash_MessageLoop_Impl::State |
16 : public base::RefCounted<PPB_Flash_MessageLoop_Impl::State> { | 17 : public base::RefCounted<PPB_Flash_MessageLoop_Impl::State> { |
17 public: | 18 public: |
18 State() : result_(PP_OK), run_called_(false), quit_called_(false) {} | 19 State() : result_(PP_OK), run_called_(false), quit_called_(false) {} |
19 | 20 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 } | 81 } |
81 state_->set_run_called(); | 82 state_->set_run_called(); |
82 state_->set_run_callback(callback); | 83 state_->set_run_callback(callback); |
83 | 84 |
84 // It is possible that the PPB_Flash_MessageLoop_Impl object has been | 85 // It is possible that the PPB_Flash_MessageLoop_Impl object has been |
85 // destroyed when the nested message loop exits. | 86 // destroyed when the nested message loop exits. |
86 scoped_refptr<State> state_protector(state_); | 87 scoped_refptr<State> state_protector(state_); |
87 { | 88 { |
88 base::MessageLoop::ScopedNestableTaskAllower allow( | 89 base::MessageLoop::ScopedNestableTaskAllower allow( |
89 base::MessageLoop::current()); | 90 base::MessageLoop::current()); |
| 91 blink::WebView::willEnterModalLoop(); |
| 92 |
90 base::MessageLoop::current()->Run(); | 93 base::MessageLoop::current()->Run(); |
| 94 |
| 95 blink::WebView::didExitModalLoop(); |
91 } | 96 } |
92 // Don't access data members of the class below. | 97 // Don't access data members of the class below. |
93 | 98 |
94 return state_protector->result(); | 99 return state_protector->result(); |
95 } | 100 } |
96 | 101 |
97 void PPB_Flash_MessageLoop_Impl::InternalQuit(int32_t result) { | 102 void PPB_Flash_MessageLoop_Impl::InternalQuit(int32_t result) { |
98 if (!state_->run_called() || state_->quit_called()) | 103 if (!state_->run_called() || state_->quit_called()) |
99 return; | 104 return; |
100 state_->set_quit_called(); | 105 state_->set_quit_called(); |
101 state_->set_result(result); | 106 state_->set_result(result); |
102 | 107 |
103 base::MessageLoop::current()->QuitNow(); | 108 base::MessageLoop::current()->QuitNow(); |
104 | 109 |
105 if (!state_->run_callback().is_null()) | 110 if (!state_->run_callback().is_null()) |
106 state_->run_callback().Run(result); | 111 state_->run_callback().Run(result); |
107 } | 112 } |
108 | 113 |
109 } // namespace content | 114 } // namespace content |
OLD | NEW |