Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef SKY_ENGINE_CORE_SCRIPT_DART_SNAPSHOT_LOADER_H_ | |
| 6 #define SKY_ENGINE_CORE_SCRIPT_DART_SNAPSHOT_LOADER_H_ | |
| 7 | |
| 8 #include "base/callback_forward.h" | |
| 9 #include "base/macros.h" | |
| 10 #include "base/memory/weak_ptr.h" | |
| 11 #include "dart/runtime/include/dart_api.h" | |
| 12 #include "mojo/common/data_pipe_drainer.h" | |
| 13 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" | |
| 14 #include "sky/engine/platform/fetcher/MojoFetcher.h" | |
| 15 #include "sky/engine/wtf/OwnPtr.h" | |
| 16 #include "sky/engine/wtf/Vector.h" | |
| 17 #include "sky/engine/wtf/text/WTFString.h" | |
| 18 | |
| 19 namespace blink { | |
| 20 | |
| 21 class DartState; | |
| 22 class KURL; | |
| 23 | |
| 24 class DartSnapshotLoader : public MojoFetcher::Client, | |
| 25 public mojo::common::DataPipeDrainer::Client { | |
| 26 public: | |
| 27 explicit DartSnapshotLoader(DartState* dart_state); | |
| 28 ~DartSnapshotLoader(); | |
| 29 | |
| 30 void LoadSnapshot(const KURL& url, mojo::URLResponsePtr response, | |
| 31 const base::Closure& callback); | |
| 32 | |
| 33 DartState* dart_state() const { return dart_state_.get(); } | |
| 34 | |
| 35 private: | |
| 36 // MojoFetcher::Client | |
| 37 void OnReceivedResponse(mojo::URLResponsePtr response) override; | |
| 38 | |
| 39 // mojo::common::DataPipeDrainer::Client | |
| 40 void OnDataAvailable(const void* data, size_t num_bytes) override; | |
| 41 void OnDataComplete() override; | |
| 42 | |
| 43 base::WeakPtr<DartState> dart_state_; | |
| 44 // TODO(abarth): Should we be using SharedBuffer to buffer the data? | |
|
eseidel
2015/06/23 06:21:39
SharedBuffer is about making the data easy to pass
eseidel
2015/06/23 06:21:39
SharedBuffer is about making the data easy to pass
abarth-chromium
2015/06/23 14:50:43
It also has a scatter/gather way of storing data s
| |
| 45 Vector<uint8_t> buffer_; | |
| 46 OwnPtr<MojoFetcher> fetcher_; | |
| 47 OwnPtr<mojo::common::DataPipeDrainer> drainer_; | |
| 48 base::Closure callback_; | |
| 49 | |
| 50 DISALLOW_COPY_AND_ASSIGN(DartSnapshotLoader); | |
| 51 }; | |
| 52 | |
| 53 } // namespace blink | |
| 54 | |
| 55 #endif // SKY_ENGINE_CORE_SCRIPT_DART_SNAPSHOT_LOADER_H_ | |
| OLD | NEW |