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

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

Issue 2637063002: Use MockResource as much as possibler in MemoryCacheCorrectnessTest (Closed)
Patch Set: override related style nits Created 3 years, 11 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
« no previous file with comments | « third_party/WebKit/Source/core/fetch/RawResource.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All Rights Reserved. 2 * Copyright (C) 2011 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 17 matching lines...) Expand all
28 #include "core/fetch/FetchRequest.h" 28 #include "core/fetch/FetchRequest.h"
29 #include "core/fetch/MemoryCache.h" 29 #include "core/fetch/MemoryCache.h"
30 #include "core/fetch/ResourceClientWalker.h" 30 #include "core/fetch/ResourceClientWalker.h"
31 #include "core/fetch/ResourceFetcher.h" 31 #include "core/fetch/ResourceFetcher.h"
32 #include "core/fetch/ResourceLoader.h" 32 #include "core/fetch/ResourceLoader.h"
33 #include "platform/HTTPNames.h" 33 #include "platform/HTTPNames.h"
34 #include <memory> 34 #include <memory>
35 35
36 namespace blink { 36 namespace blink {
37 37
38 Resource* RawResource::fetchSynchronously(FetchRequest& request, 38 RawResource* RawResource::fetchSynchronously(FetchRequest& request,
39 ResourceFetcher* fetcher) { 39 ResourceFetcher* fetcher) {
40 request.makeSynchronous(); 40 request.makeSynchronous();
41 return fetcher->requestResource(request, RawResourceFactory(Resource::Raw)); 41 return toRawResource(
42 fetcher->requestResource(request, RawResourceFactory(Resource::Raw)));
42 } 43 }
43 44
44 RawResource* RawResource::fetchImport(FetchRequest& request, 45 RawResource* RawResource::fetchImport(FetchRequest& request,
45 ResourceFetcher* fetcher) { 46 ResourceFetcher* fetcher) {
46 DCHECK_EQ(request.resourceRequest().frameType(), 47 DCHECK_EQ(request.resourceRequest().frameType(),
47 WebURLRequest::FrameTypeNone); 48 WebURLRequest::FrameTypeNone);
48 request.mutableResourceRequest().setRequestContext( 49 request.mutableResourceRequest().setRequestContext(
49 WebURLRequest::RequestContextImport); 50 WebURLRequest::RequestContextImport);
50 return toRawResource(fetcher->requestResource( 51 return toRawResource(fetcher->requestResource(
51 request, RawResourceFactory(Resource::ImportResource))); 52 request, RawResourceFactory(Resource::ImportResource)));
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 if (data()) 153 if (data())
153 client->dataReceived(this, data()->data(), data()->size()); 154 client->dataReceived(this, data()->data(), data()->size());
154 if (!hasClient(c)) 155 if (!hasClient(c))
155 return; 156 return;
156 Resource::didAddClient(client); 157 Resource::didAddClient(client);
157 } 158 }
158 159
159 bool RawResource::willFollowRedirect(const ResourceRequest& newRequest, 160 bool RawResource::willFollowRedirect(const ResourceRequest& newRequest,
160 const ResourceResponse& redirectResponse) { 161 const ResourceResponse& redirectResponse) {
161 bool follow = Resource::willFollowRedirect(newRequest, redirectResponse); 162 bool follow = Resource::willFollowRedirect(newRequest, redirectResponse);
162 // The base class method takes a non const reference of a ResourceRequest 163 // The base class method takes a const reference of a ResourceRequest and
163 // and returns bool just for allowing RawResource to reject redirect. It 164 // returns bool just for allowing RawResource to reject redirect. It must
164 // must always return true. 165 // always return true.
165 DCHECK(follow); 166 DCHECK(follow);
166 167
167 DCHECK(!redirectResponse.isNull()); 168 DCHECK(!redirectResponse.isNull());
168 ResourceClientWalker<RawResourceClient> w(clients()); 169 ResourceClientWalker<RawResourceClient> w(clients());
169 while (RawResourceClient* c = w.next()) { 170 while (RawResourceClient* c = w.next()) {
170 if (!c->redirectReceived(this, newRequest, redirectResponse)) 171 if (!c->redirectReceived(this, newRequest, redirectResponse))
171 follow = false; 172 follow = false;
172 } 173 }
173 174
174 return follow; 175 return follow;
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 SECURITY_CHECK(m_state != NotAddedAsClient); 355 SECURITY_CHECK(m_state != NotAddedAsClient);
355 SECURITY_CHECK(m_state != NotifyFinished); 356 SECURITY_CHECK(m_state != NotifyFinished);
356 SECURITY_CHECK(resource->errorOccurred() || 357 SECURITY_CHECK(resource->errorOccurred() ||
357 (m_state == ResponseReceived || 358 (m_state == ResponseReceived ||
358 m_state == SetSerializedCachedMetadata || 359 m_state == SetSerializedCachedMetadata ||
359 m_state == DataReceived || m_state == DataDownloaded)); 360 m_state == DataReceived || m_state == DataDownloaded));
360 m_state = NotifyFinished; 361 m_state = NotifyFinished;
361 } 362 }
362 363
363 } // namespace blink 364 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/RawResource.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698