Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Unified Diff: sky/engine/core/loader/CanvasImageLoader.h

Issue 1156003007: Refactor image handling in Sky (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: CR feedback from abarth Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sky/engine/core/loader/CanvasImageLoader.h
diff --git a/sky/engine/core/loader/CanvasImageLoader.h b/sky/engine/core/loader/CanvasImageLoader.h
new file mode 100644
index 0000000000000000000000000000000000000000..63db7656574dcd1fb48abf8954652125c9823579
--- /dev/null
+++ b/sky/engine/core/loader/CanvasImageLoader.h
@@ -0,0 +1,53 @@
+// SKY_ENGINE_CORE_PAINTING_CANVASIMAGE_H_
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SKY_ENGINE_CORE_LOADER_CANVASIMAGELOADER_H_
+#define SKY_ENGINE_CORE_LOADER_CANVASIMAGELOADER_H_
+
+#include "mojo/common/data_pipe_drainer.h"
+#include "sky/engine/core/loader/ImageLoaderCallback.h"
+#include "sky/engine/platform/SharedBuffer.h"
+#include "sky/engine/platform/fetcher/MojoFetcher.h"
+#include "sky/engine/tonic/dart_wrappable.h"
+#include "sky/engine/wtf/OwnPtr.h"
+#include "sky/engine/wtf/text/AtomicString.h"
+
+namespace blink {
+
+class CanvasImageLoader : public MojoFetcher::Client,
+ public mojo::common::DataPipeDrainer::Client,
+ public RefCounted<CanvasImageLoader>,
+ public DartWrappable {
+ DEFINE_WRAPPERTYPEINFO();
+ public:
+ static PassRefPtr<CanvasImageLoader> create(const String& src, PassOwnPtr<ImageLoaderCallback> callback)
+ {
+ return adoptRef(new CanvasImageLoader(src, callback));
+ }
+ virtual ~CanvasImageLoader();
+
+ void load();
+
+ // MojoFetcher::Client
+ void OnReceivedResponse(mojo::URLResponsePtr) override;
+
+ // mojo::common::DataPipeDrainer::Client
+ void OnDataAvailable(const void*, size_t) override;
+ void OnDataComplete() override;
+
+ private:
+ explicit CanvasImageLoader(const String& src, PassOwnPtr<ImageLoaderCallback> callback);
+
+ OwnPtr<MojoFetcher> fetcher_;
+ OwnPtr<mojo::common::DataPipeDrainer> drainer_;
+ RefPtr<SharedBuffer> buffer_;
+
+ KURL url_;
+ OwnPtr<ImageLoaderCallback> callback_;
+};
+
+} // namespace blink
+
+#endif // SKY_ENGINE_CORE_LOADER_CANVASIMAGELOADER_H_

Powered by Google App Engine
This is Rietveld 408576698