| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "extensions/renderer/wake_event_page.h" | 5 #include "extensions/renderer/wake_event_page.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/atomic_sequence_num.h" | 10 #include "base/atomic_sequence_num.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 base::Bind(&WakeEventPageNativeHandler::OnEventPageIsAwake, | 77 base::Bind(&WakeEventPageNativeHandler::OnEventPageIsAwake, |
| 78 weak_ptr_factory_.GetWeakPtr(), base::Passed(&callback))); | 78 weak_ptr_factory_.GetWeakPtr(), base::Passed(&callback))); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void OnEventPageIsAwake(v8::Global<v8::Function> callback, bool success) { | 81 void OnEventPageIsAwake(v8::Global<v8::Function> callback, bool success) { |
| 82 v8::Isolate* isolate = context()->isolate(); | 82 v8::Isolate* isolate = context()->isolate(); |
| 83 v8::HandleScope handle_scope(isolate); | 83 v8::HandleScope handle_scope(isolate); |
| 84 v8::Local<v8::Value> args[] = { | 84 v8::Local<v8::Value> args[] = { |
| 85 v8::Boolean::New(isolate, success), | 85 v8::Boolean::New(isolate, success), |
| 86 }; | 86 }; |
| 87 context()->CallFunction(v8::Local<v8::Function>::New(isolate, callback), | 87 context()->SafeCallFunction(v8::Local<v8::Function>::New(isolate, callback), |
| 88 arraysize(args), args); | 88 arraysize(args), args); |
| 89 } | 89 } |
| 90 | 90 |
| 91 MakeRequestCallback make_request_; | 91 MakeRequestCallback make_request_; |
| 92 base::WeakPtrFactory<WakeEventPageNativeHandler> weak_ptr_factory_; | 92 base::WeakPtrFactory<WakeEventPageNativeHandler> weak_ptr_factory_; |
| 93 | 93 |
| 94 DISALLOW_COPY_AND_ASSIGN(WakeEventPageNativeHandler); | 94 DISALLOW_COPY_AND_ASSIGN(WakeEventPageNativeHandler); |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 // static | 97 // static |
| 98 WakeEventPage* WakeEventPage::Get() { | 98 WakeEventPage* WakeEventPage::Get() { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 // call immediately. | 191 // call immediately. |
| 192 request_data->on_response.Run(success); | 192 request_data->on_response.Run(success); |
| 193 } else { | 193 } else { |
| 194 content::WorkerThread::PostTask( | 194 content::WorkerThread::PostTask( |
| 195 request_data->thread_id, | 195 request_data->thread_id, |
| 196 base::Bind(request_data->on_response, success)); | 196 base::Bind(request_data->on_response, success)); |
| 197 } | 197 } |
| 198 } | 198 } |
| 199 | 199 |
| 200 } // namespace extensions | 200 } // namespace extensions |
| OLD | NEW |