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

Side by Side Diff: third_party/WebKit/Source/core/fetch/RawResource.h

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 years, 6 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) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
3 Copyright (C) 2001 Dirk Mueller <mueller@kde.org> 3 Copyright (C) 2001 Dirk Mueller <mueller@kde.org>
4 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 4 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 5 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. 20 Boston, MA 02110-1301, USA.
21 */ 21 */
22 22
23 #ifndef RawResource_h 23 #ifndef RawResource_h
24 #define RawResource_h 24 #define RawResource_h
25 25
26 #include "core/CoreExport.h" 26 #include "core/CoreExport.h"
27 #include "core/fetch/Resource.h" 27 #include "core/fetch/Resource.h"
28 #include "core/fetch/ResourceClient.h" 28 #include "core/fetch/ResourceClient.h"
29 #include "public/platform/WebDataConsumerHandle.h" 29 #include "public/platform/WebDataConsumerHandle.h"
30 #include "wtf/PassOwnPtr.h"
31 #include "wtf/WeakPtr.h" 30 #include "wtf/WeakPtr.h"
31 #include <memory>
32 32
33 namespace blink { 33 namespace blink {
34 class FetchRequest; 34 class FetchRequest;
35 class RawResourceClient; 35 class RawResourceClient;
36 class ResourceFetcher; 36 class ResourceFetcher;
37 class SubstituteData; 37 class SubstituteData;
38 38
39 class CORE_EXPORT RawResource final : public Resource { 39 class CORE_EXPORT RawResource final : public Resource {
40 public: 40 public:
41 using ClientType = RawResourceClient; 41 using ClientType = RawResourceClient;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 RawResource(const ResourceRequest&, Type, const ResourceLoaderOptions&); 76 RawResource(const ResourceRequest&, Type, const ResourceLoaderOptions&);
77 77
78 void didAddClient(ResourceClient*) override; 78 void didAddClient(ResourceClient*) override;
79 void appendData(const char*, size_t) override; 79 void appendData(const char*, size_t) override;
80 80
81 bool shouldIgnoreHTTPStatusCodeErrors() const override { return !isLinkPrelo ad(); } 81 bool shouldIgnoreHTTPStatusCodeErrors() const override { return !isLinkPrelo ad(); }
82 82
83 void willFollowRedirect(ResourceRequest&, const ResourceResponse&) override; 83 void willFollowRedirect(ResourceRequest&, const ResourceResponse&) override;
84 void willNotFollowRedirect() override; 84 void willNotFollowRedirect() override;
85 void responseReceived(const ResourceResponse&, PassOwnPtr<WebDataConsumerHan dle>) override; 85 void responseReceived(const ResourceResponse&, std::unique_ptr<WebDataConsum erHandle>) override;
86 void setSerializedCachedMetadata(const char*, size_t) override; 86 void setSerializedCachedMetadata(const char*, size_t) override;
87 void didSendData(unsigned long long bytesSent, unsigned long long totalBytes ToBeSent) override; 87 void didSendData(unsigned long long bytesSent, unsigned long long totalBytes ToBeSent) override;
88 void didDownloadData(int) override; 88 void didDownloadData(int) override;
89 void reportResourceTimingToClients(const ResourceTimingInfo&) override; 89 void reportResourceTimingToClients(const ResourceTimingInfo&) override;
90 }; 90 };
91 91
92 #if ENABLE(SECURITY_ASSERT) 92 #if ENABLE(SECURITY_ASSERT)
93 inline bool isRawResource(const Resource& resource) 93 inline bool isRawResource(const Resource& resource)
94 { 94 {
95 Resource::Type type = resource.getType(); 95 Resource::Type type = resource.getType();
96 return type == Resource::MainResource || type == Resource::Raw || type == Re source::TextTrack || type == Resource::Media || type == Resource::Manifest || ty pe == Resource::ImportResource; 96 return type == Resource::MainResource || type == Resource::Raw || type == Re source::TextTrack || type == Resource::Media || type == Resource::Manifest || ty pe == Resource::ImportResource;
97 } 97 }
98 #endif 98 #endif
99 inline RawResource* toRawResource(Resource* resource) 99 inline RawResource* toRawResource(Resource* resource)
100 { 100 {
101 ASSERT_WITH_SECURITY_IMPLICATION(!resource || isRawResource(*resource)); 101 ASSERT_WITH_SECURITY_IMPLICATION(!resource || isRawResource(*resource));
102 return static_cast<RawResource*>(resource); 102 return static_cast<RawResource*>(resource);
103 } 103 }
104 104
105 class CORE_EXPORT RawResourceClient : public ResourceClient { 105 class CORE_EXPORT RawResourceClient : public ResourceClient {
106 public: 106 public:
107 RawResourceClient() 107 RawResourceClient()
108 : m_weakFactory(this) { } 108 : m_weakFactory(this) { }
109 WeakPtr<RawResourceClient> createWeakPtr() { return m_weakFactory.createWeak Ptr(); } 109 WeakPtr<RawResourceClient> createWeakPtr() { return m_weakFactory.createWeak Ptr(); }
110 ~RawResourceClient() override {} 110 ~RawResourceClient() override {}
111 static bool isExpectedType(ResourceClient* client) { return client->getResou rceClientType() == RawResourceType; } 111 static bool isExpectedType(ResourceClient* client) { return client->getResou rceClientType() == RawResourceType; }
112 ResourceClientType getResourceClientType() const final { return RawResourceT ype; } 112 ResourceClientType getResourceClientType() const final { return RawResourceT ype; }
113 113
114 virtual void dataSent(Resource*, unsigned long long /* bytesSent */, unsigne d long long /* totalBytesToBeSent */) { } 114 virtual void dataSent(Resource*, unsigned long long /* bytesSent */, unsigne d long long /* totalBytesToBeSent */) { }
115 virtual void responseReceived(Resource*, const ResourceResponse&, PassOwnPtr <WebDataConsumerHandle>) { } 115 virtual void responseReceived(Resource*, const ResourceResponse&, std::uniqu e_ptr<WebDataConsumerHandle>) { }
116 virtual void setSerializedCachedMetadata(Resource*, const char*, size_t) { } 116 virtual void setSerializedCachedMetadata(Resource*, const char*, size_t) { }
117 virtual void dataReceived(Resource*, const char* /* data */, size_t /* lengt h */) { } 117 virtual void dataReceived(Resource*, const char* /* data */, size_t /* lengt h */) { }
118 virtual void redirectReceived(Resource*, ResourceRequest&, const ResourceRes ponse&) { } 118 virtual void redirectReceived(Resource*, ResourceRequest&, const ResourceRes ponse&) { }
119 virtual void redirectBlocked() {} 119 virtual void redirectBlocked() {}
120 virtual void dataDownloaded(Resource*, int) { } 120 virtual void dataDownloaded(Resource*, int) { }
121 virtual void didReceiveResourceTiming(Resource*, const ResourceTimingInfo&) { } 121 virtual void didReceiveResourceTiming(Resource*, const ResourceTimingInfo&) { }
122 122
123 private: 123 private:
124 WeakPtrFactory<RawResourceClient> m_weakFactory; 124 WeakPtrFactory<RawResourceClient> m_weakFactory;
125 }; 125 };
126 126
127 } // namespace blink 127 } // namespace blink
128 128
129 #endif // RawResource_h 129 #endif // RawResource_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/MemoryCacheTest.cpp ('k') | third_party/WebKit/Source/core/fetch/RawResource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698