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

Side by Side Diff: Source/modules/imagebitmap/ImageBitmapFactories.h

Issue 297513008: Decrease call sites of ScriptState::current() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013, Google Inc. All rights reserved. 2 * Copyright (c) 2013, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 15 matching lines...) Expand all
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef ImageBitmapFactories_h 31 #ifndef ImageBitmapFactories_h
32 #define ImageBitmapFactories_h 32 #define ImageBitmapFactories_h
33 33
34 #include "bindings/v8/ScriptPromise.h" 34 #include "bindings/v8/ScriptPromise.h"
35 #include "bindings/v8/ScriptPromiseResolverWithContext.h" 35 #include "bindings/v8/ScriptPromiseResolverWithContext.h"
36 #include "bindings/v8/ScriptState.h"
36 #include "core/fileapi/FileReaderLoader.h" 37 #include "core/fileapi/FileReaderLoader.h"
37 #include "core/fileapi/FileReaderLoaderClient.h" 38 #include "core/fileapi/FileReaderLoaderClient.h"
38 #include "platform/Supplementable.h" 39 #include "platform/Supplementable.h"
39 #include "platform/geometry/IntRect.h" 40 #include "platform/geometry/IntRect.h"
40 #include "wtf/Forward.h" 41 #include "wtf/Forward.h"
41 #include "wtf/HashSet.h" 42 #include "wtf/HashSet.h"
42 43
43 namespace WebCore { 44 namespace WebCore {
44 45
45 class Blob; 46 class Blob;
(...skipping 29 matching lines...) Expand all
75 virtual ~ImageBitmapFactories() { } 76 virtual ~ImageBitmapFactories() { }
76 77
77 void trace(Visitor*); 78 void trace(Visitor*);
78 79
79 protected: 80 protected:
80 static const char* supplementName(); 81 static const char* supplementName();
81 82
82 private: 83 private:
83 class ImageBitmapLoader FINAL : public RefCountedWillBeGarbageCollectedFinal ized<ImageBitmapLoader>, public FileReaderLoaderClient { 84 class ImageBitmapLoader FINAL : public RefCountedWillBeGarbageCollectedFinal ized<ImageBitmapLoader>, public FileReaderLoaderClient {
84 public: 85 public:
85 static PassRefPtrWillBeRawPtr<ImageBitmapLoader> create(ImageBitmapFacto ries& factory, ExecutionContext* context, const IntRect& cropRect) 86 static PassRefPtrWillBeRawPtr<ImageBitmapLoader> create(ImageBitmapFacto ries& factory, const IntRect& cropRect, ScriptState* scriptState)
86 { 87 {
87 return adoptRefWillBeNoop(new ImageBitmapLoader(factory, context, cr opRect)); 88 return adoptRefWillBeNoop(new ImageBitmapLoader(factory, cropRect, s criptState));
88 } 89 }
89 90
90 void loadBlobAsync(ExecutionContext*, Blob*); 91 void loadBlobAsync(ExecutionContext*, Blob*);
91 ScriptPromise promise() { return m_resolver->promise(); } 92 ScriptPromise promise() { return m_resolver->promise(); }
92 93
93 void trace(Visitor*); 94 void trace(Visitor*);
94 95
95 virtual ~ImageBitmapLoader() { } 96 virtual ~ImageBitmapLoader() { }
96 97
97 private: 98 private:
98 ImageBitmapLoader(ImageBitmapFactories&, ExecutionContext*, const IntRec t&); 99 ImageBitmapLoader(ImageBitmapFactories&, const IntRect&, ScriptState*);
99 100
100 void rejectPromise(); 101 void rejectPromise();
101 102
102 // FileReaderLoaderClient 103 // FileReaderLoaderClient
103 virtual void didStartLoading() OVERRIDE { } 104 virtual void didStartLoading() OVERRIDE { }
104 virtual void didReceiveData() OVERRIDE { } 105 virtual void didReceiveData() OVERRIDE { }
105 virtual void didFinishLoading() OVERRIDE; 106 virtual void didFinishLoading() OVERRIDE;
106 virtual void didFail(FileError::ErrorCode) OVERRIDE; 107 virtual void didFail(FileError::ErrorCode) OVERRIDE;
107 108
108 FileReaderLoader m_loader; 109 FileReaderLoader m_loader;
109 RawPtrWillBeMember<ImageBitmapFactories> m_factory; 110 RawPtrWillBeMember<ImageBitmapFactories> m_factory;
110 RefPtr<ScriptPromiseResolverWithContext> m_resolver; 111 RefPtr<ScriptPromiseResolverWithContext> m_resolver;
111 IntRect m_cropRect; 112 IntRect m_cropRect;
112 }; 113 };
113 114
114 static ImageBitmapFactories& from(EventTarget&); 115 static ImageBitmapFactories& from(EventTarget&);
115 116
116 template<class GlobalObject> 117 template<class GlobalObject>
117 static ImageBitmapFactories& fromInternal(GlobalObject&); 118 static ImageBitmapFactories& fromInternal(GlobalObject&);
118 119
119 void addLoader(PassRefPtrWillBeRawPtr<ImageBitmapLoader>); 120 void addLoader(PassRefPtrWillBeRawPtr<ImageBitmapLoader>);
120 void didFinishLoading(ImageBitmapLoader*); 121 void didFinishLoading(ImageBitmapLoader*);
121 122
122 WillBeHeapHashSet<RefPtrWillBeMember<ImageBitmapLoader> > m_pendingLoaders; 123 WillBeHeapHashSet<RefPtrWillBeMember<ImageBitmapLoader> > m_pendingLoaders;
123 }; 124 };
124 125
125 } // namespace WebCore 126 } // namespace WebCore
126 127
127 #endif // ImageBitmapFactories_h 128 #endif // ImageBitmapFactories_h
OLDNEW
« no previous file with comments | « Source/core/css/MediaQueryListListener.cpp ('k') | Source/modules/imagebitmap/ImageBitmapFactories.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698