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

Side by Side Diff: third_party/WebKit/Source/platform/exported/WrappedResourceResponse.h

Issue 2117313002: Remove WebURLResponse::initialize() [revised] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months 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
OLDNEW
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 21 matching lines...) Expand all
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 class WrappedResourceResponse : public WebURLResponse { 40 class WrappedResourceResponse : public WebURLResponse {
41 public: 41 public:
42 ~WrappedResourceResponse() 42 ~WrappedResourceResponse() {}
43 WrappedResourceResponse() : WebURLResponse(&m_handle) {}
44
45 explicit WrappedResourceResponse(ResourceResponse& resourceResponse)
46 : WebURLResponse(&m_handle)
43 { 47 {
44 reset(); // Need to drop reference to m_handle 48 m_handle.setResourceResponse(resourceResponse);
45 } 49 }
46 50
47 WrappedResourceResponse() { } 51 explicit WrappedResourceResponse(const ResourceResponse& resourceResponse)
48 52 : WrappedResourceResponse(const_cast<ResourceResponse&>(resourceResponse ))
49 WrappedResourceResponse(ResourceResponse& resourceResponse)
50 { 53 {
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 } 54 }
64 55
65 void bind(const ResourceResponse& resourceResponse) 56 void bind(const ResourceResponse& resourceResponse)
66 { 57 {
67 bind(*const_cast<ResourceResponse*>(&resourceResponse)); 58 m_handle.setResourceResponse(resourceResponse);
68 } 59 }
69 60
70 private: 61 private:
71 class Handle : public WebURLResponsePrivate { 62 class Handle : public WebURLResponsePrivate {
72 DISALLOW_NEW(); 63 DISALLOW_NEW();
73 public: 64 public:
74 virtual void dispose() { m_resourceResponse = 0; } 65 const ResourceResponse* resourceResponse() const override
66 {
67 return m_resourceResponse;
68 }
69
70 ResourceResponse* resourceResponse() override
71 {
72 return m_resourceResponse;
Adam Rice 2016/07/06 01:39:00 We could optionally track whether the ResourceResp
73 }
74
75 void setResourceResponse(const ResourceResponse& response) override
76 {
77 m_resourceResponse = const_cast<ResourceResponse*>(&response);
78 }
79
80 private:
81 ResourceResponse* m_resourceResponse = nullptr;
75 }; 82 };
76 83
77 Handle m_handle; 84 Handle m_handle;
78 }; 85 };
79 86
80 } // namespace blink 87 } // namespace blink
81 88
82 #endif 89 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698