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