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

Side by Side Diff: mojo/edk/js/drain_data.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/drain_data.h" 5 #include "mojo/edk/js/drain_data.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "gin/array_buffer.h" 12 #include "gin/array_buffer.h"
13 #include "gin/converter.h" 13 #include "gin/converter.h"
14 #include "gin/dictionary.h" 14 #include "gin/dictionary.h"
15 #include "gin/per_context_data.h" 15 #include "gin/per_context_data.h"
16 #include "gin/per_isolate_data.h" 16 #include "gin/per_isolate_data.h"
17 #include "mojo/public/cpp/system/core.h" 17 #include "mojo/public/cpp/system/core.h"
18 18
19 namespace mojo { 19 namespace mojo {
20 namespace edk { 20 namespace edk {
21 namespace js { 21 namespace js {
22 22
23 DrainData::DrainData(v8::Isolate* isolate, mojo::Handle handle) 23 DrainData::DrainData(v8::Isolate* isolate, mojo::Handle handle)
24 : isolate_(isolate), 24 : isolate_(isolate),
25 handle_(DataPipeConsumerHandle(handle.value())), 25 handle_(DataPipeConsumerHandle(handle.value())),
26 handle_watcher_(FROM_HERE) { 26 handle_watcher_(FROM_HERE, Watcher::ArmingPolicy::AUTOMATIC) {
27 v8::Handle<v8::Context> context(isolate_->GetCurrentContext()); 27 v8::Handle<v8::Context> context(isolate_->GetCurrentContext());
28 runner_ = gin::PerContextData::From(context)->runner()->GetWeakPtr(); 28 runner_ = gin::PerContextData::From(context)->runner()->GetWeakPtr();
29 29
30 WaitForData(); 30 WaitForData();
31 } 31 }
32 32
33 v8::Handle<v8::Value> DrainData::GetPromise() { 33 v8::Handle<v8::Value> DrainData::GetPromise() {
34 CHECK(resolver_.IsEmpty()); 34 CHECK(resolver_.IsEmpty());
35 v8::Handle<v8::Promise::Resolver> resolver( 35 v8::Handle<v8::Promise::Resolver> resolver(
36 v8::Promise::Resolver::New(isolate_)); 36 v8::Promise::Resolver::New(isolate_));
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 resolver->Resolve(settled_value); 120 resolver->Resolve(settled_value);
121 else 121 else
122 resolver->Reject(settled_value); 122 resolver->Reject(settled_value);
123 123
124 delete this; 124 delete this;
125 } 125 }
126 126
127 } // namespace js 127 } // namespace js
128 } // namespace edk 128 } // namespace edk
129 } // namespace mojo 129 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698