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

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

Issue 701683005: Service Workers/Fetch: Fix Response constructor for empty/null (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 Response_h 5 #ifndef Response_h
6 #define Response_h 6 #define Response_h
7 7
8 #include "bindings/core/v8/Dictionary.h" 8 #include "bindings/core/v8/Dictionary.h"
9 #include "bindings/core/v8/ScriptWrappable.h" 9 #include "bindings/core/v8/ScriptWrappable.h"
10 #include "modules/serviceworkers/Body.h" 10 #include "modules/serviceworkers/Body.h"
11 #include "modules/serviceworkers/FetchResponseData.h" 11 #include "modules/serviceworkers/FetchResponseData.h"
12 #include "modules/serviceworkers/Headers.h" 12 #include "modules/serviceworkers/Headers.h"
13 #include "platform/blob/BlobData.h" 13 #include "platform/blob/BlobData.h"
14 #include "platform/heap/Handle.h" 14 #include "platform/heap/Handle.h"
15 15
16 namespace blink { 16 namespace blink {
17 17
18 class Blob; 18 class Blob;
19 class DOMArrayBuffer; 19 class DOMArrayBuffer;
20 class DOMArrayBufferView; 20 class DOMArrayBufferView;
21 class ExceptionState; 21 class ExceptionState;
22 class ResponseInit; 22 class ResponseInit;
23 class WebServiceWorkerResponse; 23 class WebServiceWorkerResponse;
24 24
25 class Response final : public Body { 25 class Response final : public Body {
26 DEFINE_WRAPPERTYPEINFO(); 26 DEFINE_WRAPPERTYPEINFO();
27 public: 27 public:
28 virtual ~Response() { } 28 virtual ~Response() { }
29 // Constructors from Response.idl:
30 static Response* create(ExecutionContext*, ExceptionState&);
29 static Response* create(ExecutionContext*, Blob*, const Dictionary&, Excepti onState&); 31 static Response* create(ExecutionContext*, Blob*, const Dictionary&, Excepti onState&);
30 static Response* create(ExecutionContext*, const String&, const Dictionary&, ExceptionState&); 32 static Response* create(ExecutionContext*, const String&, const Dictionary&, ExceptionState&);
31 static Response* create(ExecutionContext*, const DOMArrayBuffer*, const Dict ionary&, ExceptionState&); 33 static Response* create(ExecutionContext*, const DOMArrayBuffer*, const Dict ionary&, ExceptionState&);
32 static Response* create(ExecutionContext*, const DOMArrayBufferView*, const Dictionary&, ExceptionState&); 34 static Response* create(ExecutionContext*, const DOMArrayBufferView*, const Dictionary&, ExceptionState&);
35
33 static Response* create(ExecutionContext*, Blob*, const ResponseInit&, Excep tionState&); 36 static Response* create(ExecutionContext*, Blob*, const ResponseInit&, Excep tionState&);
34 static Response* create(ExecutionContext*, FetchResponseData*); 37 static Response* create(ExecutionContext*, FetchResponseData*);
35 static Response* create(ExecutionContext*, const WebServiceWorkerResponse&); 38 static Response* create(ExecutionContext*, const WebServiceWorkerResponse&);
36 // The 'FetchResponseData' object is shared between responses, as it is 39 // The 'FetchResponseData' object is shared between responses, as it is
37 // immutable to the user after Response creation. Headers are copied. 40 // immutable to the user after Response creation. Headers are copied.
38 static Response* create(const Response&); 41 static Response* create(const Response&);
39 42
40 const FetchResponseData* response() const { return m_response; } 43 const FetchResponseData* response() const { return m_response; }
41 44
45 // From Response.idl:
42 String type() const; 46 String type() const;
43 String url() const; 47 String url() const;
44 unsigned short status() const; 48 unsigned short status() const;
45 String statusText() const; 49 String statusText() const;
46 Headers* headers() const; 50 Headers* headers() const;
47 51
52 // From Response.idl:
48 Response* clone() const; 53 Response* clone() const;
49 54
50 void populateWebServiceWorkerResponse(WebServiceWorkerResponse&); 55 void populateWebServiceWorkerResponse(WebServiceWorkerResponse&);
51 56
52 virtual void trace(Visitor*) override; 57 virtual void trace(Visitor*) override;
53 58
54 private: 59 private:
55 explicit Response(const Response&); 60 explicit Response(const Response&);
56 explicit Response(ExecutionContext*); 61 explicit Response(ExecutionContext*);
57 Response(ExecutionContext*, FetchResponseData*); 62 Response(ExecutionContext*, FetchResponseData*);
58 63
59 virtual PassRefPtr<BlobDataHandle> blobDataHandle() override; 64 virtual PassRefPtr<BlobDataHandle> blobDataHandle() override;
60 65
61 const Member<FetchResponseData> m_response; 66 const Member<FetchResponseData> m_response;
62 const Member<Headers> m_headers; 67 const Member<Headers> m_headers;
63 }; 68 };
64 69
65 } // namespace blink 70 } // namespace blink
66 71
67 #endif // Response_h 72 #endif // Response_h
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/serviceworker/resources/response-content-worker.js ('k') | Source/modules/serviceworkers/Response.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698