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

Side by Side Diff: third_party/WebKit/Source/web/WebDataSourceImpl.cpp

Issue 2832713002: Move WebDataSourceImpl from web/ -> core/exported/. (Closed)
Patch Set: Need to add BLINK_EXPORT to WebDataSource for windows to compile. Created 3 years, 7 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
(Empty)
1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
29 */
30
31 #include "web/WebDataSourceImpl.h"
32
33 #include <memory>
34 #include "core/dom/Document.h"
35 #include "core/loader/SubresourceFilter.h"
36 #include "platform/wtf/PtrUtil.h"
37 #include "public/platform/WebDocumentSubresourceFilter.h"
38 #include "public/platform/WebURL.h"
39 #include "public/platform/WebURLError.h"
40 #include "public/platform/WebVector.h"
41 #include "public/platform/modules/serviceworker/WebServiceWorkerNetworkProvider. h"
42
43 namespace blink {
44
45 WebDataSourceImpl* WebDataSourceImpl::Create(
46 LocalFrame* frame,
47 const ResourceRequest& request,
48 const SubstituteData& data,
49 ClientRedirectPolicy client_redirect_policy) {
50 DCHECK(frame);
51
52 return new WebDataSourceImpl(frame, request, data, client_redirect_policy);
53 }
54
55 const WebURLRequest& WebDataSourceImpl::OriginalRequest() const {
56 return original_request_wrapper_;
57 }
58
59 const WebURLRequest& WebDataSourceImpl::GetRequest() const {
60 return request_wrapper_;
61 }
62
63 const WebURLResponse& WebDataSourceImpl::GetResponse() const {
64 return response_wrapper_;
65 }
66
67 bool WebDataSourceImpl::HasUnreachableURL() const {
68 return !DocumentLoader::UnreachableURL().IsEmpty();
69 }
70
71 WebURL WebDataSourceImpl::UnreachableURL() const {
72 return DocumentLoader::UnreachableURL();
73 }
74
75 void WebDataSourceImpl::AppendRedirect(const WebURL& url) {
76 DocumentLoader::AppendRedirect(url);
77 }
78
79 void WebDataSourceImpl::UpdateNavigation(double redirect_start_time,
80 double redirect_end_time,
81 double fetch_start_time,
82 bool has_redirect) {
83 // Updates the redirection timing if there is at least one redirection
84 // (between two URLs).
85 if (has_redirect) {
86 GetTiming().SetRedirectStart(redirect_start_time);
87 GetTiming().SetRedirectEnd(redirect_end_time);
88 }
89 GetTiming().SetFetchStart(fetch_start_time);
90 }
91
92 void WebDataSourceImpl::RedirectChain(WebVector<WebURL>& result) const {
93 result.Assign(redirect_chain_);
94 }
95
96 bool WebDataSourceImpl::IsClientRedirect() const {
97 return DocumentLoader::IsClientRedirect();
98 }
99
100 bool WebDataSourceImpl::ReplacesCurrentHistoryItem() const {
101 return DocumentLoader::ReplacesCurrentHistoryItem();
102 }
103
104 WebNavigationType WebDataSourceImpl::GetNavigationType() const {
105 return ToWebNavigationType(DocumentLoader::GetNavigationType());
106 }
107
108 WebDataSource::ExtraData* WebDataSourceImpl::GetExtraData() const {
109 return extra_data_.get();
110 }
111
112 void WebDataSourceImpl::SetExtraData(ExtraData* extra_data) {
113 // extraData can't be a std::unique_ptr because setExtraData is a WebKit API
114 // function.
115 extra_data_ = WTF::WrapUnique(extra_data);
116 }
117
118 void WebDataSourceImpl::SetNavigationStartTime(double navigation_start) {
119 GetTiming().SetNavigationStart(navigation_start);
120 }
121
122 WebNavigationType WebDataSourceImpl::ToWebNavigationType(NavigationType type) {
123 switch (type) {
124 case kNavigationTypeLinkClicked:
125 return kWebNavigationTypeLinkClicked;
126 case kNavigationTypeFormSubmitted:
127 return kWebNavigationTypeFormSubmitted;
128 case kNavigationTypeBackForward:
129 return kWebNavigationTypeBackForward;
130 case kNavigationTypeReload:
131 return kWebNavigationTypeReload;
132 case kNavigationTypeFormResubmitted:
133 return kWebNavigationTypeFormResubmitted;
134 case kNavigationTypeOther:
135 default:
136 return kWebNavigationTypeOther;
137 }
138 }
139
140 WebDataSourceImpl::WebDataSourceImpl(
141 LocalFrame* frame,
142 const ResourceRequest& request,
143 const SubstituteData& data,
144 ClientRedirectPolicy client_redirect_policy)
145 : DocumentLoader(frame, request, data, client_redirect_policy),
146 original_request_wrapper_(DocumentLoader::OriginalRequest()),
147 request_wrapper_(DocumentLoader::GetRequest()),
148 response_wrapper_(DocumentLoader::GetResponse()) {}
149
150 WebDataSourceImpl::~WebDataSourceImpl() {
151 // Verify that detachFromFrame() has been called.
152 DCHECK(!extra_data_);
153 }
154
155 void WebDataSourceImpl::DetachFromFrame() {
156 DocumentLoader::DetachFromFrame();
157 extra_data_.reset();
158 }
159
160 void WebDataSourceImpl::SetSubresourceFilter(
161 WebDocumentSubresourceFilter* subresource_filter) {
162 DocumentLoader::SetSubresourceFilter(
163 SubresourceFilter::Create(this, WTF::WrapUnique(subresource_filter)));
164 }
165
166 void WebDataSourceImpl::SetServiceWorkerNetworkProvider(
167 std::unique_ptr<WebServiceWorkerNetworkProvider> provider) {
168 DocumentLoader::SetServiceWorkerNetworkProvider(std::move(provider));
169 }
170
171 WebServiceWorkerNetworkProvider*
172 WebDataSourceImpl::GetServiceWorkerNetworkProvider() {
173 return DocumentLoader::GetServiceWorkerNetworkProvider();
174 }
175
176 void WebDataSourceImpl::SetSourceLocation(
177 const WebSourceLocation& source_location) {
178 std::unique_ptr<SourceLocation> location =
179 SourceLocation::Create(source_location.url, source_location.line_number,
180 source_location.column_number, nullptr);
181 DocumentLoader::SetSourceLocation(std::move(location));
182 }
183
184 void WebDataSourceImpl::ResetSourceLocation() {
185 DocumentLoader::SetSourceLocation(nullptr);
186 }
187
188 DEFINE_TRACE(WebDataSourceImpl) {
189 DocumentLoader::Trace(visitor);
190 }
191
192 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebDataSourceImpl.h ('k') | third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698