OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "mojo/apps/js/bindings/waiting_callback.h" | 5 #include "mojo/apps/js/bindings/waiting_callback.h" |
6 | 6 |
7 #include "gin/per_context_data.h" | 7 #include "gin/per_context_data.h" |
8 #include "gin/per_isolate_data.h" | 8 #include "gin/per_isolate_data.h" |
9 | 9 |
10 namespace mojo { | 10 namespace mojo { |
(...skipping 12 matching lines...) Expand all Loading... |
23 : wait_id_() { | 23 : wait_id_() { |
24 v8::Handle<v8::Context> context = isolate->GetCurrentContext(); | 24 v8::Handle<v8::Context> context = isolate->GetCurrentContext(); |
25 runner_ = gin::PerContextData::From(context)->runner()->GetWeakPtr(); | 25 runner_ = gin::PerContextData::From(context)->runner()->GetWeakPtr(); |
26 GetWrapper(isolate)->SetHiddenValue(GetHiddenPropertyName(isolate), callback); | 26 GetWrapper(isolate)->SetHiddenValue(GetHiddenPropertyName(isolate), callback); |
27 } | 27 } |
28 | 28 |
29 WaitingCallback::~WaitingCallback() { | 29 WaitingCallback::~WaitingCallback() { |
30 DCHECK(!wait_id_) << "Waiting callback was destroyed before being cancelled."; | 30 DCHECK(!wait_id_) << "Waiting callback was destroyed before being cancelled."; |
31 } | 31 } |
32 | 32 |
33 scoped_refptr<WaitingCallback> WaitingCallback::Create( | 33 gin::Handle<WaitingCallback> WaitingCallback::Create( |
34 v8::Isolate* isolate, v8::Handle<v8::Function> callback) { | 34 v8::Isolate* isolate, v8::Handle<v8::Function> callback) { |
35 return make_scoped_refptr(new WaitingCallback(isolate, callback)); | 35 return gin::CreateHandle(isolate, new WaitingCallback(isolate, callback)); |
36 } | 36 } |
37 | 37 |
38 gin::WrapperInfo WaitingCallback::kWrapperInfo = { gin::kEmbedderNativeGin }; | 38 gin::WrapperInfo WaitingCallback::kWrapperInfo = { gin::kEmbedderNativeGin }; |
39 | 39 |
40 gin::WrapperInfo* WaitingCallback::GetWrapperInfo() { | 40 gin::WrapperInfo* WaitingCallback::GetWrapperInfo() { |
41 return &kWrapperInfo; | 41 return &kWrapperInfo; |
42 } | 42 } |
43 | 43 |
44 void WaitingCallback::EnsureRegistered(v8::Isolate* isolate) { | 44 void WaitingCallback::EnsureRegistered(v8::Isolate* isolate) { |
45 gin::PerIsolateData* data = gin::PerIsolateData::From(isolate); | 45 gin::PerIsolateData* data = gin::PerIsolateData::From(isolate); |
(...skipping 17 matching lines...) Expand all Loading... |
63 GetWrapper(isolate)->GetHiddenValue(GetHiddenPropertyName(isolate)); | 63 GetWrapper(isolate)->GetHiddenValue(GetHiddenPropertyName(isolate)); |
64 v8::Handle<v8::Function> callback; | 64 v8::Handle<v8::Function> callback; |
65 CHECK(gin::ConvertFromV8(isolate, hidden_value, &callback)); | 65 CHECK(gin::ConvertFromV8(isolate, hidden_value, &callback)); |
66 | 66 |
67 v8::Handle<v8::Value> args[] = { gin::ConvertToV8(isolate, result) }; | 67 v8::Handle<v8::Value> args[] = { gin::ConvertToV8(isolate, result) }; |
68 runner_->Call(callback, runner_->global(), 1, args); | 68 runner_->Call(callback, runner_->global(), 1, args); |
69 } | 69 } |
70 | 70 |
71 } // namespace js | 71 } // namespace js |
72 } // namespace mojo | 72 } // namespace mojo |
OLD | NEW |