OLD | NEW |
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 #ifndef MOJO_EDK_JS_DRAIN_DATA_H_ | 5 #ifndef MOJO_EDK_JS_DRAIN_DATA_H_ |
6 #define MOJO_EDK_JS_DRAIN_DATA_H_ | 6 #define MOJO_EDK_JS_DRAIN_DATA_H_ |
7 | 7 |
8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
9 #include "gin/runner.h" | 9 #include "gin/runner.h" |
10 #include "mojo/public/c/environment/async_waiter.h" | 10 #include "mojo/public/c/environment/async_waiter.h" |
11 #include "mojo/public/cpp/system/core.h" | 11 #include "mojo/public/cpp/system/core.h" |
12 #include "v8/include/v8.h" | 12 #include "v8/include/v8.h" |
13 | 13 |
14 namespace mojo { | 14 namespace mojo { |
15 namespace edk { | 15 namespace edk { |
| 16 namespace js { |
16 | 17 |
17 // This class is the implementation of the Mojo JavaScript core module's | 18 // This class is the implementation of the Mojo JavaScript core module's |
18 // drainData() method. It is not intended to be used directly. The caller | 19 // drainData() method. It is not intended to be used directly. The caller |
19 // allocates a DrainData on the heap and returns GetPromise() to JS. The | 20 // allocates a DrainData on the heap and returns GetPromise() to JS. The |
20 // implementation deletes itself after reading as much data as possible | 21 // implementation deletes itself after reading as much data as possible |
21 // and rejecting or resolving the Promise. | 22 // and rejecting or resolving the Promise. |
22 | 23 |
23 class DrainData { | 24 class DrainData { |
24 public: | 25 public: |
25 // Starts waiting for data on the specified data pipe consumer handle. | 26 // Starts waiting for data on the specified data pipe consumer handle. |
(...skipping 25 matching lines...) Expand all Loading... |
51 using DataBuffer = std::vector<char>; | 52 using DataBuffer = std::vector<char>; |
52 | 53 |
53 v8::Isolate* isolate_; | 54 v8::Isolate* isolate_; |
54 ScopedDataPipeConsumerHandle handle_; | 55 ScopedDataPipeConsumerHandle handle_; |
55 MojoAsyncWaitID wait_id_; | 56 MojoAsyncWaitID wait_id_; |
56 base::WeakPtr<gin::Runner> runner_; | 57 base::WeakPtr<gin::Runner> runner_; |
57 v8::UniquePersistent<v8::Promise::Resolver> resolver_; | 58 v8::UniquePersistent<v8::Promise::Resolver> resolver_; |
58 ScopedVector<DataBuffer> data_buffers_; | 59 ScopedVector<DataBuffer> data_buffers_; |
59 }; | 60 }; |
60 | 61 |
| 62 } // namespace js |
61 } // namespace edk | 63 } // namespace edk |
62 } // namespace mojo | 64 } // namespace mojo |
63 | 65 |
64 #endif // MOJO_EDK_JS_DRAIN_DATA_H_ | 66 #endif // MOJO_EDK_JS_DRAIN_DATA_H_ |
OLD | NEW |