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 <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "gin/runner.h" | 11 #include "gin/runner.h" |
12 #include "mojo/public/cpp/system/core.h" | 12 #include "mojo/public/cpp/system/core.h" |
13 #include "mojo/public/cpp/system/watcher.h" | 13 #include "mojo/public/cpp/system/simple_watcher.h" |
14 #include "v8/include/v8.h" | 14 #include "v8/include/v8.h" |
15 | 15 |
16 namespace mojo { | 16 namespace mojo { |
17 namespace edk { | 17 namespace edk { |
18 namespace js { | 18 namespace js { |
19 | 19 |
20 // This class is the implementation of the Mojo JavaScript core module's | 20 // This class is the implementation of the Mojo JavaScript core module's |
21 // drainData() method. It is not intended to be used directly. The caller | 21 // drainData() method. It is not intended to be used directly. The caller |
22 // allocates a DrainData on the heap and returns GetPromise() to JS. The | 22 // allocates a DrainData on the heap and returns GetPromise() to JS. The |
23 // implementation deletes itself after reading as much data as possible | 23 // implementation deletes itself after reading as much data as possible |
(...skipping 21 matching lines...) Expand all Loading... |
45 MojoResult ReadData(); | 45 MojoResult ReadData(); |
46 | 46 |
47 // When the remote data pipe handle is closed, or an error occurs, deliver | 47 // When the remote data pipe handle is closed, or an error occurs, deliver |
48 // all of the buffered data to the JS Promise and then delete this. | 48 // all of the buffered data to the JS Promise and then delete this. |
49 void DeliverData(MojoResult result); | 49 void DeliverData(MojoResult result); |
50 | 50 |
51 using DataBuffer = std::vector<char>; | 51 using DataBuffer = std::vector<char>; |
52 | 52 |
53 v8::Isolate* isolate_; | 53 v8::Isolate* isolate_; |
54 ScopedDataPipeConsumerHandle handle_; | 54 ScopedDataPipeConsumerHandle handle_; |
55 Watcher handle_watcher_; | 55 SimpleWatcher handle_watcher_; |
56 base::WeakPtr<gin::Runner> runner_; | 56 base::WeakPtr<gin::Runner> runner_; |
57 v8::UniquePersistent<v8::Promise::Resolver> resolver_; | 57 v8::UniquePersistent<v8::Promise::Resolver> resolver_; |
58 std::vector<std::unique_ptr<DataBuffer>> data_buffers_; | 58 std::vector<std::unique_ptr<DataBuffer>> data_buffers_; |
59 }; | 59 }; |
60 | 60 |
61 } // namespace js | 61 } // namespace js |
62 } // namespace edk | 62 } // namespace edk |
63 } // namespace mojo | 63 } // namespace mojo |
64 | 64 |
65 #endif // MOJO_EDK_JS_DRAIN_DATA_H_ | 65 #endif // MOJO_EDK_JS_DRAIN_DATA_H_ |
OLD | NEW |