Home | History | Annotate | Download | only in serviceworkers
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef Response_h
      6 #define Response_h
      7 
      8 #include "bindings/core/v8/Dictionary.h"
      9 #include "bindings/core/v8/ScriptWrappable.h"
     10 #include "modules/serviceworkers/Body.h"
     11 #include "modules/serviceworkers/FetchResponseData.h"
     12 #include "modules/serviceworkers/Headers.h"
     13 #include "platform/blob/BlobData.h"
     14 #include "platform/heap/Handle.h"
     15 #include "wtf/Forward.h"
     16 
     17 namespace blink {
     18 
     19 class Blob;
     20 class ExceptionState;
     21 class ResponseInit;
     22 class WebServiceWorkerResponse;
     23 
     24 class Response FINAL : public Body {
     25     DEFINE_WRAPPERTYPEINFO();
     26 public:
     27     virtual ~Response() { }
     28     static Response* create(ExecutionContext*, Blob*, const Dictionary&, ExceptionState&);
     29     static Response* create(ExecutionContext*, const String&, const Dictionary&, ExceptionState&);
     30     static Response* create(ExecutionContext*, const ArrayBuffer*, const Dictionary&, ExceptionState&);
     31     static Response* create(ExecutionContext*, const ArrayBufferView*, const Dictionary&, ExceptionState&);
     32     static Response* create(ExecutionContext*, Blob*, const ResponseInit&, ExceptionState&);
     33     static Response* create(ExecutionContext*, FetchResponseData*);
     34     static Response* create(ExecutionContext*, const WebServiceWorkerResponse&);
     35     // The 'FetchResponseData' object is shared between responses, as it is
     36     // immutable to the user after Response creation. Headers are copied.
     37     static Response* create(const Response&);
     38 
     39     String type() const;
     40     String url() const;
     41     unsigned short status() const;
     42     String statusText() const;
     43     Headers* headers() const;
     44 
     45     Response* clone() const;
     46 
     47     void populateWebServiceWorkerResponse(WebServiceWorkerResponse&);
     48 
     49     virtual void trace(Visitor*) OVERRIDE;
     50 
     51 private:
     52     explicit Response(const Response&);
     53     explicit Response(ExecutionContext*);
     54     Response(ExecutionContext*, FetchResponseData*);
     55     Response(ExecutionContext*, const WebServiceWorkerResponse&);
     56 
     57     virtual PassRefPtr<BlobDataHandle> blobDataHandle() OVERRIDE;
     58 
     59     const Member<FetchResponseData> m_response;
     60     const Member<Headers> m_headers;
     61 };
     62 
     63 } // namespace blink
     64 
     65 #endif // Response_h
     66