OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 SKY_ENGINE_TONIC_DART_SNAPSHOT_LOADER_H_ | 5 #ifndef SKY_ENGINE_TONIC_DART_SNAPSHOT_LOADER_H_ |
6 #define SKY_ENGINE_TONIC_DART_SNAPSHOT_LOADER_H_ | 6 #define SKY_ENGINE_TONIC_DART_SNAPSHOT_LOADER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "dart/runtime/include/dart_api.h" | 13 #include "dart/runtime/include/dart_api.h" |
14 #include "mojo/common/data_pipe_drainer.h" | 14 #include "mojo/common/data_pipe_drainer.h" |
15 #include "sky/engine/wtf/OwnPtr.h" | 15 #include "sky/engine/wtf/OwnPtr.h" |
16 #include "sky/engine/wtf/text/WTFString.h" | |
17 | 16 |
18 namespace blink { | 17 namespace blink { |
19 class DartState; | 18 class DartState; |
20 | 19 |
21 class DartSnapshotLoader : public mojo::common::DataPipeDrainer::Client { | 20 class DartSnapshotLoader : public mojo::common::DataPipeDrainer::Client { |
22 public: | 21 public: |
23 explicit DartSnapshotLoader(DartState* dart_state); | 22 explicit DartSnapshotLoader(DartState* dart_state); |
24 ~DartSnapshotLoader(); | 23 ~DartSnapshotLoader(); |
25 | 24 |
26 void LoadSnapshot(mojo::ScopedDataPipeConsumerHandle pipe, | 25 void LoadSnapshot(mojo::ScopedDataPipeConsumerHandle pipe, |
27 const base::Closure& callback); | 26 const base::Closure& callback); |
28 | 27 |
29 private: | 28 private: |
30 // mojo::common::DataPipeDrainer::Client | 29 // mojo::common::DataPipeDrainer::Client |
31 void OnDataAvailable(const void* data, size_t num_bytes) override; | 30 void OnDataAvailable(const void* data, size_t num_bytes) override; |
32 void OnDataComplete() override; | 31 void OnDataComplete() override; |
33 | 32 |
34 base::WeakPtr<DartState> dart_state_; | 33 base::WeakPtr<DartState> dart_state_; |
35 OwnPtr<mojo::common::DataPipeDrainer> drainer_; | 34 OwnPtr<mojo::common::DataPipeDrainer> drainer_; |
36 // TODO(abarth): Should we be using SharedBuffer to buffer the data? | 35 // TODO(abarth): Should we be using SharedBuffer to buffer the data? |
37 std::vector<uint8_t> buffer_; | 36 std::vector<uint8_t> buffer_; |
38 base::Closure callback_; | 37 base::Closure callback_; |
39 | 38 |
40 DISALLOW_COPY_AND_ASSIGN(DartSnapshotLoader); | 39 DISALLOW_COPY_AND_ASSIGN(DartSnapshotLoader); |
41 }; | 40 }; |
42 | 41 |
43 } // namespace blink | 42 } // namespace blink |
44 | 43 |
45 #endif // SKY_ENGINE_TONIC_DART_SNAPSHOT_LOADER_H_ | 44 #endif // SKY_ENGINE_TONIC_DART_SNAPSHOT_LOADER_H_ |
OLD | NEW |