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

Side by Side Diff: mojo/edk/js/waiting_callback.cc

Issue 2725133002: Mojo: Armed Watchers (Closed)
Patch Set: . Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/edk/js/waiting_callback.h" 5 #include "mojo/edk/js/waiting_callback.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "gin/per_context_data.h" 9 #include "gin/per_context_data.h"
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 void WaitingCallback::Cancel() { 47 void WaitingCallback::Cancel() {
48 if (watcher_.IsWatching()) 48 if (watcher_.IsWatching())
49 watcher_.Cancel(); 49 watcher_.Cancel();
50 } 50 }
51 51
52 WaitingCallback::WaitingCallback(v8::Isolate* isolate, 52 WaitingCallback::WaitingCallback(v8::Isolate* isolate,
53 v8::Handle<v8::Function> callback, 53 v8::Handle<v8::Function> callback,
54 bool one_shot) 54 bool one_shot)
55 : one_shot_(one_shot), 55 : one_shot_(one_shot),
56 watcher_(FROM_HERE), 56 watcher_(FROM_HERE, Watcher::ArmingPolicy::AUTOMATIC),
57 weak_factory_(this) { 57 weak_factory_(this) {
58 v8::Handle<v8::Context> context = isolate->GetCurrentContext(); 58 v8::Handle<v8::Context> context = isolate->GetCurrentContext();
59 runner_ = gin::PerContextData::From(context)->runner()->GetWeakPtr(); 59 runner_ = gin::PerContextData::From(context)->runner()->GetWeakPtr();
60 GetWrapper(isolate) 60 GetWrapper(isolate)
61 ->SetPrivate(context, GetHiddenPropertyName(isolate), callback) 61 ->SetPrivate(context, GetHiddenPropertyName(isolate), callback)
62 .FromJust(); 62 .FromJust();
63 } 63 }
64 64
65 WaitingCallback::~WaitingCallback() { 65 WaitingCallback::~WaitingCallback() {
66 Cancel(); 66 Cancel();
(...skipping 19 matching lines...) Expand all
86 86
87 if (one_shot_ || result == MOJO_RESULT_CANCELLED) { 87 if (one_shot_ || result == MOJO_RESULT_CANCELLED) {
88 runner_.reset(); 88 runner_.reset();
89 Cancel(); 89 Cancel();
90 } 90 }
91 } 91 }
92 92
93 } // namespace js 93 } // namespace js
94 } // namespace edk 94 } // namespace edk
95 } // namespace mojo 95 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698