Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Side by Side Diff: mojo/apps/js/bindings/waiting_callback.cc

Issue 134253004: Mojo: AsyncWaiter and mojo/public/environment (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add missing files Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 8
9 namespace mojo { 9 namespace mojo {
10 namespace js { 10 namespace js {
(...skipping 18 matching lines...) Expand all
29 29
30 WaitingCallback::~WaitingCallback() { 30 WaitingCallback::~WaitingCallback() {
31 DCHECK(!wait_id_) << "Waiting callback was destroyed before being cancelled."; 31 DCHECK(!wait_id_) << "Waiting callback was destroyed before being cancelled.";
32 } 32 }
33 33
34 gin::Handle<WaitingCallback> WaitingCallback::Create( 34 gin::Handle<WaitingCallback> WaitingCallback::Create(
35 v8::Isolate* isolate, v8::Handle<v8::Function> callback) { 35 v8::Isolate* isolate, v8::Handle<v8::Function> callback) {
36 return gin::CreateHandle(isolate, new WaitingCallback(isolate, callback)); 36 return gin::CreateHandle(isolate, new WaitingCallback(isolate, callback));
37 } 37 }
38 38
39 // static
40 void WaitingCallback::CallOnHandleReady(void* closure, MojoResult result) {
41 static_cast<WaitingCallback*>(closure)->OnHandleReady(result);
42 }
43
39 void WaitingCallback::OnHandleReady(MojoResult result) { 44 void WaitingCallback::OnHandleReady(MojoResult result) {
40 wait_id_ = NULL; 45 wait_id_ = 0;
41 46
42 if (!runner_) 47 if (!runner_)
43 return; 48 return;
44 49
45 gin::Runner::Scope scope(runner_.get()); 50 gin::Runner::Scope scope(runner_.get());
46 v8::Isolate* isolate = runner_->isolate(); 51 v8::Isolate* isolate = runner_->isolate();
47 52
48 v8::Handle<v8::Value> hidden_value = 53 v8::Handle<v8::Value> hidden_value =
49 GetWrapper(isolate)->GetHiddenValue(GetHiddenPropertyName(isolate)); 54 GetWrapper(isolate)->GetHiddenValue(GetHiddenPropertyName(isolate));
50 v8::Handle<v8::Function> callback; 55 v8::Handle<v8::Function> callback;
51 CHECK(gin::ConvertFromV8(isolate, hidden_value, &callback)); 56 CHECK(gin::ConvertFromV8(isolate, hidden_value, &callback));
52 57
53 v8::Handle<v8::Value> args[] = { gin::ConvertToV8(isolate, result) }; 58 v8::Handle<v8::Value> args[] = { gin::ConvertToV8(isolate, result) };
54 runner_->Call(callback, runner_->global(), 1, args); 59 runner_->Call(callback, runner_->global(), 1, args);
55 } 60 }
56 61
57 } // namespace js 62 } // namespace js
58 } // namespace mojo 63 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698