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

Side by Side Diff: third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.h

Issue 1609313002: Use BlobCallback in toBlob instead of FileCallback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase master and Renamed mimeType to contentType to match other bits in Blob.h Created 4 years, 11 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 unified diff | Download patch
OLDNEW
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 #include "core/CoreExport.h" 5 #include "core/CoreExport.h"
6 #include "core/dom/DOMTypedArray.h" 6 #include "core/dom/DOMTypedArray.h"
7 #include "core/dom/ExecutionContext.h" 7 #include "core/dom/ExecutionContext.h"
8 #include "core/fileapi/FileCallback.h" 8 #include "core/fileapi/BlobCallback.h"
9 #include "platform/geometry/IntSize.h" 9 #include "platform/geometry/IntSize.h"
10 #include "platform/heap/Handle.h" 10 #include "platform/heap/Handle.h"
11 #include "wtf/OwnPtr.h" 11 #include "wtf/OwnPtr.h"
12 #include "wtf/PassOwnPtr.h" 12 #include "wtf/PassOwnPtr.h"
13 #include "wtf/Vector.h" 13 #include "wtf/Vector.h"
14 #include "wtf/text/WTFString.h" 14 #include "wtf/text/WTFString.h"
15 15
16 namespace blink { 16 namespace blink {
17 17
18 class PNGImageEncoderState; 18 class PNGImageEncoderState;
19 19
20 class CORE_EXPORT CanvasAsyncBlobCreator 20 class CORE_EXPORT CanvasAsyncBlobCreator
21 : public RefCounted<CanvasAsyncBlobCreator> { 21 : public RefCounted<CanvasAsyncBlobCreator> {
22 public: 22 public:
23 static PassRefPtr<CanvasAsyncBlobCreator> create(PassRefPtr<DOMUint8ClampedA rray> unpremultipliedRGBAImageData, const String& mimeType, const IntSize&, File Callback*, ExecutionContext*); 23 static PassRefPtr<CanvasAsyncBlobCreator> create(PassRefPtr<DOMUint8ClampedA rray> unpremultipliedRGBAImageData, const String& mimeType, const IntSize&, Blob Callback*, ExecutionContext*);
24 void scheduleAsyncBlobCreation(bool canUseIdlePeriodScheduling, double quali ty = 0.0); 24 void scheduleAsyncBlobCreation(bool canUseIdlePeriodScheduling, double quali ty = 0.0);
25 virtual ~CanvasAsyncBlobCreator(); 25 virtual ~CanvasAsyncBlobCreator();
26 26
27 protected: 27 protected:
28 CanvasAsyncBlobCreator(PassRefPtr<DOMUint8ClampedArray> data, const String& mimeType, const IntSize&, FileCallback*); 28 CanvasAsyncBlobCreator(PassRefPtr<DOMUint8ClampedArray> data, const String& mimeType, const IntSize&, BlobCallback*);
29 virtual void scheduleCreateBlobAndCallOnMainThread(); 29 virtual void scheduleCreateBlobAndCallOnMainThread();
30 virtual void scheduleCreateNullptrAndCallOnMainThread(); 30 virtual void scheduleCreateNullptrAndCallOnMainThread();
31 virtual void scheduleClearSelfRefOnMainThread(); 31 virtual void scheduleClearSelfRefOnMainThread();
32 std::atomic<bool> m_cancelled; 32 std::atomic<bool> m_cancelled;
33 33
34 private: 34 private:
35 friend class CanvasAsyncBlobCreatorTest; 35 friend class CanvasAsyncBlobCreatorTest;
36 36
37 OwnPtr<PNGImageEncoderState> m_encoderState; 37 OwnPtr<PNGImageEncoderState> m_encoderState;
38 RefPtr<DOMUint8ClampedArray> m_data; 38 RefPtr<DOMUint8ClampedArray> m_data;
39 OwnPtr<Vector<unsigned char>> m_encodedImage; 39 OwnPtr<Vector<unsigned char>> m_encodedImage;
40 int m_numRowsCompleted; 40 int m_numRowsCompleted;
41 41
42 const IntSize m_size; 42 const IntSize m_size;
43 size_t m_pixelRowStride; 43 size_t m_pixelRowStride;
44 const String m_mimeType; 44 const String m_mimeType;
45 Persistent<FileCallback> m_callback; 45 Persistent<BlobCallback> m_callback;
46 46
47 RefPtr<CanvasAsyncBlobCreator> m_selfRef; 47 RefPtr<CanvasAsyncBlobCreator> m_selfRef;
48 void clearSelfReference(); 48 void clearSelfReference();
49 49
50 void initiatePngEncoding(double deadlineSeconds); 50 void initiatePngEncoding(double deadlineSeconds);
51 void scheduleIdleEncodeRowsPng(); 51 void scheduleIdleEncodeRowsPng();
52 void idleEncodeRowsPng(double deadlineSeconds); 52 void idleEncodeRowsPng(double deadlineSeconds);
53 53
54 void createBlobAndCall(); 54 void createBlobAndCall();
55 55
56 void encodeImageOnEncoderThread(double quality); 56 void encodeImageOnEncoderThread(double quality);
57 bool initializeEncodeImageOnEncoderThread(); 57 bool initializeEncodeImageOnEncoderThread();
58 void nonprogressiveEncodeImageOnEncoderThread(double quality); 58 void nonprogressiveEncodeImageOnEncoderThread(double quality);
59 void progressiveEncodeImageOnEncoderThread(); 59 void progressiveEncodeImageOnEncoderThread();
60 60
61 class ContextObserver; 61 class ContextObserver;
62 void createContextObserver(ExecutionContext*); 62 void createContextObserver(ExecutionContext*);
63 OwnPtrWillBePersistent<ContextObserver> m_contextObserver; 63 OwnPtrWillBePersistent<ContextObserver> m_contextObserver;
64 }; 64 };
65 65
66 } // namespace blink 66 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698