OLD | NEW |
1 // SKY_ENGINE_CORE_PAINTING_CANVASIMAGE_H_ | 1 // SKY_ENGINE_CORE_PAINTING_CANVASIMAGE_H_ |
2 // Copyright 2015 The Chromium Authors. All rights reserved. | 2 // Copyright 2015 The Chromium Authors. All rights reserved. |
3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
5 | 5 |
6 #ifndef SKY_ENGINE_CORE_LOADER_CANVASIMAGELOADER_H_ | 6 #ifndef SKY_ENGINE_CORE_LOADER_CANVASIMAGELOADER_H_ |
7 #define SKY_ENGINE_CORE_LOADER_CANVASIMAGELOADER_H_ | 7 #define SKY_ENGINE_CORE_LOADER_CANVASIMAGELOADER_H_ |
8 | 8 |
9 #include "mojo/common/data_pipe_drainer.h" | 9 #include "mojo/common/data_pipe_drainer.h" |
10 #include "sky/engine/core/loader/ImageLoaderCallback.h" | 10 #include "sky/engine/core/loader/ImageDecoderCallback.h" |
11 #include "sky/engine/platform/SharedBuffer.h" | 11 #include "sky/engine/platform/SharedBuffer.h" |
12 #include "sky/engine/platform/fetcher/MojoFetcher.h" | |
13 #include "sky/engine/tonic/dart_wrappable.h" | 12 #include "sky/engine/tonic/dart_wrappable.h" |
14 #include "sky/engine/wtf/OwnPtr.h" | 13 #include "sky/engine/wtf/OwnPtr.h" |
15 #include "sky/engine/wtf/text/AtomicString.h" | 14 #include "sky/engine/wtf/text/AtomicString.h" |
16 | 15 |
17 namespace blink { | 16 namespace blink { |
18 | 17 |
19 class CanvasImageLoader : public MojoFetcher::Client, | 18 class CanvasImageDecoder : public mojo::common::DataPipeDrainer::Client, |
20 public mojo::common::DataPipeDrainer::Client, | 19 public RefCounted<CanvasImageDecoder>, |
21 public RefCounted<CanvasImageLoader>, | 20 public DartWrappable { |
22 public DartWrappable { | |
23 DEFINE_WRAPPERTYPEINFO(); | 21 DEFINE_WRAPPERTYPEINFO(); |
24 public: | 22 public: |
25 static PassRefPtr<CanvasImageLoader> create(const String& src, PassOwnPtr<Imag
eLoaderCallback> callback) | 23 static PassRefPtr<CanvasImageDecoder> create(mojo::ScopedDataPipeConsumerHandl
e handle, PassOwnPtr<ImageDecoderCallback> callback); |
26 { | 24 virtual ~CanvasImageDecoder(); |
27 return adoptRef(new CanvasImageLoader(src, callback)); | |
28 } | |
29 virtual ~CanvasImageLoader(); | |
30 | |
31 // MojoFetcher::Client | |
32 void OnReceivedResponse(mojo::URLResponsePtr) override; | |
33 | 25 |
34 // mojo::common::DataPipeDrainer::Client | 26 // mojo::common::DataPipeDrainer::Client |
35 void OnDataAvailable(const void*, size_t) override; | 27 void OnDataAvailable(const void*, size_t) override; |
36 void OnDataComplete() override; | 28 void OnDataComplete() override; |
37 | 29 |
38 private: | 30 private: |
39 explicit CanvasImageLoader(const String& src, PassOwnPtr<ImageLoaderCallback>
callback); | 31 CanvasImageDecoder(mojo::ScopedDataPipeConsumerHandle handle, PassOwnPtr<Image
DecoderCallback> callback); |
40 | 32 |
41 OwnPtr<MojoFetcher> fetcher_; | |
42 OwnPtr<mojo::common::DataPipeDrainer> drainer_; | 33 OwnPtr<mojo::common::DataPipeDrainer> drainer_; |
43 RefPtr<SharedBuffer> buffer_; | 34 RefPtr<SharedBuffer> buffer_; |
44 OwnPtr<ImageLoaderCallback> callback_; | 35 OwnPtr<ImageDecoderCallback> callback_; |
45 }; | 36 }; |
46 | 37 |
47 } // namespace blink | 38 } // namespace blink |
48 | 39 |
49 #endif // SKY_ENGINE_CORE_LOADER_CANVASIMAGELOADER_H_ | 40 #endif // SKY_ENGINE_CORE_LOADER_CANVASIMAGELOADER_H_ |
OLD | NEW |