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

Unified Diff: mojo/apps/js/bindings/waiting_callback.cc

Issue 189453003: Moves around mojo js bindings code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/apps/js/bindings/waiting_callback.h ('k') | mojo/apps/js/main.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/apps/js/bindings/waiting_callback.cc
diff --git a/mojo/apps/js/bindings/waiting_callback.cc b/mojo/apps/js/bindings/waiting_callback.cc
deleted file mode 100644
index 923431630d3a2f38eae85c942a8f770442f34655..0000000000000000000000000000000000000000
--- a/mojo/apps/js/bindings/waiting_callback.cc
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "mojo/apps/js/bindings/waiting_callback.h"
-
-#include "gin/per_context_data.h"
-
-namespace mojo {
-namespace js {
-
-namespace {
-
-v8::Handle<v8::String> GetHiddenPropertyName(v8::Isolate* isolate) {
- return gin::StringToSymbol(isolate, "::mojo::js::WaitingCallback");
-}
-
-} // namespace
-
-gin::WrapperInfo WaitingCallback::kWrapperInfo = { gin::kEmbedderNativeGin };
-
-WaitingCallback::WaitingCallback(v8::Isolate* isolate,
- v8::Handle<v8::Function> callback)
- : wait_id_() {
- v8::Handle<v8::Context> context = isolate->GetCurrentContext();
- runner_ = gin::PerContextData::From(context)->runner()->GetWeakPtr();
- GetWrapper(isolate)->SetHiddenValue(GetHiddenPropertyName(isolate), callback);
-}
-
-WaitingCallback::~WaitingCallback() {
- DCHECK(!wait_id_) << "Waiting callback was destroyed before being cancelled.";
-}
-
-gin::Handle<WaitingCallback> WaitingCallback::Create(
- v8::Isolate* isolate, v8::Handle<v8::Function> callback) {
- return gin::CreateHandle(isolate, new WaitingCallback(isolate, callback));
-}
-
-// static
-void WaitingCallback::CallOnHandleReady(void* closure, MojoResult result) {
- static_cast<WaitingCallback*>(closure)->OnHandleReady(result);
-}
-
-void WaitingCallback::OnHandleReady(MojoResult result) {
- wait_id_ = 0;
-
- if (!runner_)
- return;
-
- gin::Runner::Scope scope(runner_.get());
- v8::Isolate* isolate = runner_->GetContextHolder()->isolate();
-
- v8::Handle<v8::Value> hidden_value =
- GetWrapper(isolate)->GetHiddenValue(GetHiddenPropertyName(isolate));
- v8::Handle<v8::Function> callback;
- CHECK(gin::ConvertFromV8(isolate, hidden_value, &callback));
-
- v8::Handle<v8::Value> args[] = { gin::ConvertToV8(isolate, result) };
- runner_->Call(callback, runner_->global(), 1, args);
-}
-
-} // namespace js
-} // namespace mojo
« no previous file with comments | « mojo/apps/js/bindings/waiting_callback.h ('k') | mojo/apps/js/main.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698