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

Side by Side Diff: Source/modules/serviceworkers/Body.h

Issue 708703002: Service Worker: Cache.put() consumes request/response bodies (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Inline hasBody methods Created 6 years, 1 month 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef Body_h 5 #ifndef Body_h
6 #define Body_h 6 #define Body_h
7 7
8 #include "bindings/core/v8/ScriptPromise.h" 8 #include "bindings/core/v8/ScriptPromise.h"
9 #include "bindings/core/v8/ScriptPromiseResolver.h" 9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "bindings/core/v8/ScriptWrappable.h" 10 #include "bindings/core/v8/ScriptWrappable.h"
(...skipping 25 matching lines...) Expand all
36 ResponseAsJSON, 36 ResponseAsJSON,
37 ResponseAsText 37 ResponseAsText
38 }; 38 };
39 39
40 ScriptPromise arrayBuffer(ScriptState*); 40 ScriptPromise arrayBuffer(ScriptState*);
41 ScriptPromise blob(ScriptState*); 41 ScriptPromise blob(ScriptState*);
42 ScriptPromise formData(ScriptState*); 42 ScriptPromise formData(ScriptState*);
43 ScriptPromise json(ScriptState*); 43 ScriptPromise json(ScriptState*);
44 ScriptPromise text(ScriptState*); 44 ScriptPromise text(ScriptState*);
45 45
46 // Sets the bodyUsed flag to true. This signifies that the contents of the
47 // body have been consumed and cannot be accessed again.
48 void setBodyUsed();
46 bool bodyUsed() const; 49 bool bodyUsed() const;
47 50
48 // ActiveDOMObject override. 51 // ActiveDOMObject override.
49 virtual void stop() override; 52 virtual void stop() override;
50 virtual bool hasPendingActivity() const override; 53 virtual bool hasPendingActivity() const override;
51 54
52 virtual void trace(Visitor*) { } 55 virtual void trace(Visitor*) { }
53 56
54 protected: 57 protected:
55 // Copy constructor for clone() implementations 58 // Copy constructor for clone() implementations
56 explicit Body(const Body&); 59 explicit Body(const Body&);
57 60
58 // Sets the bodyUsed flag to true. This signifies that the contents of the
59 // body have been consumed and cannot be accessed again.
60 void setBodyUsed();
61
62 private: 61 private:
63 ScriptPromise readAsync(ScriptState*, ResponseType); 62 ScriptPromise readAsync(ScriptState*, ResponseType);
64 void resolveJSON(); 63 void resolveJSON();
65 64
66 // FileReaderLoaderClient functions. 65 // FileReaderLoaderClient functions.
67 virtual void didStartLoading() override; 66 virtual void didStartLoading() override;
68 virtual void didReceiveData() override; 67 virtual void didReceiveData() override;
69 virtual void didFinishLoading() override; 68 virtual void didFinishLoading() override;
70 virtual void didFail(FileError::ErrorCode) override; 69 virtual void didFail(FileError::ErrorCode) override;
71 70
72 virtual PassRefPtr<BlobDataHandle> blobDataHandle() = 0; 71 virtual PassRefPtr<BlobDataHandle> blobDataHandle() = 0;
73 72
74 OwnPtr<FileReaderLoader> m_loader; 73 OwnPtr<FileReaderLoader> m_loader;
75 bool m_bodyUsed; 74 bool m_bodyUsed;
76 ResponseType m_responseType; 75 ResponseType m_responseType;
77 RefPtr<ScriptPromiseResolver> m_resolver; 76 RefPtr<ScriptPromiseResolver> m_resolver;
78 }; 77 };
79 78
80 } // namespace blink 79 } // namespace blink
81 80
82 #endif // Body_h 81 #endif // Body_h
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/serviceworker/resources/cache-put-worker.js ('k') | Source/modules/serviceworkers/Cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698