| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 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 WrappedResourceRequest_h | 31 #ifndef WrappedResourceRequest_h |
| 32 #define WrappedResourceRequest_h | 32 #define WrappedResourceRequest_h |
| 33 | 33 |
| 34 #include "platform/exported/WebURLRequestPrivate.h" | |
| 35 #include "public/platform/WebURLRequest.h" | 34 #include "public/platform/WebURLRequest.h" |
| 36 #include "wtf/Allocator.h" | 35 #include "wtf/Allocator.h" |
| 37 #include "wtf/Noncopyable.h" | 36 #include "wtf/Noncopyable.h" |
| 38 | 37 |
| 39 namespace blink { | 38 namespace blink { |
| 40 | 39 |
| 40 // WrappedResourceRequest doesn't take ownership of given ResourceRequest, |
| 41 // but just holds a pointer to it. It is not copyable. |
| 41 class WrappedResourceRequest : public WebURLRequest { | 42 class WrappedResourceRequest : public WebURLRequest { |
| 43 WTF_MAKE_NONCOPYABLE(WrappedResourceRequest); |
| 42 public: | 44 public: |
| 43 ~WrappedResourceRequest() | 45 ~WrappedResourceRequest() {} |
| 46 |
| 47 explicit WrappedResourceRequest(ResourceRequest& resourceRequest) |
| 48 : WebURLRequest(resourceRequest) |
| 44 { | 49 { |
| 45 reset(); // Need to drop reference to m_handle | |
| 46 } | 50 } |
| 47 | 51 |
| 48 WrappedResourceRequest() { } | 52 explicit WrappedResourceRequest(const ResourceRequest& resourceRequest) |
| 49 | 53 : WrappedResourceRequest(const_cast<ResourceRequest&>(resourceRequest)) |
| 50 WrappedResourceRequest(ResourceRequest& resourceRequest) | |
| 51 { | 54 { |
| 52 bind(resourceRequest); | |
| 53 } | 55 } |
| 54 | |
| 55 WrappedResourceRequest(const ResourceRequest& resourceRequest) | |
| 56 { | |
| 57 bind(resourceRequest); | |
| 58 } | |
| 59 | |
| 60 void bind(ResourceRequest& resourceRequest) | |
| 61 { | |
| 62 m_handle.m_resourceRequest = &resourceRequest; | |
| 63 assign(&m_handle); | |
| 64 } | |
| 65 | |
| 66 void bind(const ResourceRequest& resourceRequest) | |
| 67 { | |
| 68 bind(*const_cast<ResourceRequest*>(&resourceRequest)); | |
| 69 } | |
| 70 | |
| 71 private: | |
| 72 class Handle final : public WebURLRequestPrivate { | |
| 73 DISALLOW_NEW(); | |
| 74 public: | |
| 75 Handle() { } | |
| 76 | |
| 77 virtual void dispose() { m_resourceRequest = 0; } | |
| 78 }; | |
| 79 | |
| 80 Handle m_handle; | |
| 81 }; | 56 }; |
| 82 | 57 |
| 83 } // namespace blink | 58 } // namespace blink |
| 84 | 59 |
| 85 #endif | 60 #endif |
| OLD | NEW |