| 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 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 #ifndef WrappedResourceResponse_h | 31 #ifndef WrappedResourceResponse_h |
| 32 #define WrappedResourceResponse_h | 32 #define WrappedResourceResponse_h |
| 33 | 33 |
| 34 #include "platform/exported/WebURLResponsePrivate.h" | 34 #include "platform/exported/WebURLResponsePrivate.h" |
| 35 #include "public/platform/WebURLResponse.h" | 35 #include "public/platform/WebURLResponse.h" |
| 36 #include "wtf/Allocator.h" | 36 #include "wtf/Allocator.h" |
| 37 | 37 |
| 38 namespace blink { | 38 namespace blink { |
| 39 | 39 |
| 40 // WrappedResourceResponse doesn't take ownership of given ResourceResponse, |
| 41 // but just holds a pointer to it. It is not copyable (as WebURLResponsePrivate |
| 42 // is non-copyable). |
| 40 class WrappedResourceResponse : public WebURLResponse { | 43 class WrappedResourceResponse : public WebURLResponse { |
| 41 public: | 44 public: |
| 42 ~WrappedResourceResponse() | 45 ~WrappedResourceResponse() {} |
| 46 |
| 47 explicit WrappedResourceResponse(ResourceResponse& resourceResponse) |
| 48 : WebURLResponse(&m_handle) |
| 43 { | 49 { |
| 44 reset(); // Need to drop reference to m_handle | 50 m_handle.m_resourceResponse = &resourceResponse; |
| 45 } | 51 } |
| 46 | 52 |
| 47 WrappedResourceResponse() { } | 53 explicit WrappedResourceResponse(const ResourceResponse& resourceResponse) |
| 48 | 54 : WrappedResourceResponse(const_cast<ResourceResponse&>(resourceResponse
)) |
| 49 WrappedResourceResponse(ResourceResponse& resourceResponse) | |
| 50 { | 55 { |
| 51 bind(resourceResponse); | |
| 52 } | |
| 53 | |
| 54 WrappedResourceResponse(const ResourceResponse& resourceResponse) | |
| 55 { | |
| 56 bind(resourceResponse); | |
| 57 } | |
| 58 | |
| 59 void bind(ResourceResponse& resourceResponse) | |
| 60 { | |
| 61 m_handle.m_resourceResponse = &resourceResponse; | |
| 62 assign(&m_handle); | |
| 63 } | |
| 64 | |
| 65 void bind(const ResourceResponse& resourceResponse) | |
| 66 { | |
| 67 bind(*const_cast<ResourceResponse*>(&resourceResponse)); | |
| 68 } | 56 } |
| 69 | 57 |
| 70 private: | 58 private: |
| 71 class Handle : public WebURLResponsePrivate { | 59 // This is pointed by m_private. |
| 72 DISALLOW_NEW(); | 60 WebURLResponsePrivate m_handle; |
| 73 public: | |
| 74 virtual void dispose() { m_resourceResponse = 0; } | |
| 75 }; | |
| 76 | |
| 77 Handle m_handle; | |
| 78 }; | 61 }; |
| 79 | 62 |
| 80 } // namespace blink | 63 } // namespace blink |
| 81 | 64 |
| 82 #endif | 65 #endif |
| OLD | NEW |