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

Side by Side Diff: content/test/weburl_loader_mock.cc

Issue 63253002: Rename WebKit namespace to blink (part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « content/test/weburl_loader_mock.h ('k') | content/test/weburl_loader_mock_factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/test/weburl_loader_mock.h" 5 #include "content/test/weburl_loader_mock.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/test/weburl_loader_mock_factory.h" 8 #include "content/test/weburl_loader_mock_factory.h"
9 #include "third_party/WebKit/public/platform/WebData.h" 9 #include "third_party/WebKit/public/platform/WebData.h"
10 #include "third_party/WebKit/public/platform/WebURLError.h" 10 #include "third_party/WebKit/public/platform/WebURLError.h"
11 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" 11 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
12 12
13 WebURLLoaderMock::WebURLLoaderMock(WebURLLoaderMockFactory* factory, 13 WebURLLoaderMock::WebURLLoaderMock(WebURLLoaderMockFactory* factory,
14 WebKit::WebURLLoader* default_loader) 14 blink::WebURLLoader* default_loader)
15 : factory_(factory), 15 : factory_(factory),
16 client_(NULL), 16 client_(NULL),
17 default_loader_(default_loader), 17 default_loader_(default_loader),
18 using_default_loader_(false), 18 using_default_loader_(false),
19 is_deferred_(false) { 19 is_deferred_(false) {
20 } 20 }
21 21
22 WebURLLoaderMock::~WebURLLoaderMock() { 22 WebURLLoaderMock::~WebURLLoaderMock() {
23 } 23 }
24 24
25 void WebURLLoaderMock::ServeAsynchronousRequest( 25 void WebURLLoaderMock::ServeAsynchronousRequest(
26 const WebKit::WebURLResponse& response, 26 const blink::WebURLResponse& response,
27 const WebKit::WebData& data, 27 const blink::WebData& data,
28 const WebKit::WebURLError& error) { 28 const blink::WebURLError& error) {
29 DCHECK(!using_default_loader_); 29 DCHECK(!using_default_loader_);
30 if (!client_) 30 if (!client_)
31 return; 31 return;
32 32
33 client_->didReceiveResponse(this, response); 33 client_->didReceiveResponse(this, response);
34 34
35 if (error.reason) { 35 if (error.reason) {
36 client_->didFail(this, error); 36 client_->didFail(this, error);
37 return; 37 return;
38 } 38 }
39 client_->didReceiveData(this, data.data(), data.size(), data.size()); 39 client_->didReceiveData(this, data.data(), data.size(), data.size());
40 client_->didFinishLoading(this, 0); 40 client_->didFinishLoading(this, 0);
41 } 41 }
42 42
43 WebKit::WebURLRequest WebURLLoaderMock::ServeRedirect( 43 blink::WebURLRequest WebURLLoaderMock::ServeRedirect(
44 const WebKit::WebURLResponse& redirectResponse) { 44 const blink::WebURLResponse& redirectResponse) {
45 WebKit::WebURLRequest newRequest; 45 blink::WebURLRequest newRequest;
46 newRequest.initialize(); 46 newRequest.initialize();
47 GURL redirectURL(redirectResponse.httpHeaderField("Location")); 47 GURL redirectURL(redirectResponse.httpHeaderField("Location"));
48 newRequest.setURL(redirectURL); 48 newRequest.setURL(redirectURL);
49 client_->willSendRequest(this, newRequest, redirectResponse); 49 client_->willSendRequest(this, newRequest, redirectResponse);
50 return newRequest; 50 return newRequest;
51 } 51 }
52 52
53 void WebURLLoaderMock::loadSynchronously(const WebKit::WebURLRequest& request, 53 void WebURLLoaderMock::loadSynchronously(const blink::WebURLRequest& request,
54 WebKit::WebURLResponse& response, 54 blink::WebURLResponse& response,
55 WebKit::WebURLError& error, 55 blink::WebURLError& error,
56 WebKit::WebData& data) { 56 blink::WebData& data) {
57 if (factory_->IsMockedURL(request.url())) { 57 if (factory_->IsMockedURL(request.url())) {
58 factory_->LoadSynchronously(request, &response, &error, &data); 58 factory_->LoadSynchronously(request, &response, &error, &data);
59 return; 59 return;
60 } 60 }
61 DCHECK(static_cast<const GURL&>(request.url()).SchemeIs("data")) 61 DCHECK(static_cast<const GURL&>(request.url()).SchemeIs("data"))
62 << "loadSynchronously shouldn't be falling back: " 62 << "loadSynchronously shouldn't be falling back: "
63 << request.url().spec().data(); 63 << request.url().spec().data();
64 using_default_loader_ = true; 64 using_default_loader_ = true;
65 default_loader_->loadSynchronously(request, response, error, data); 65 default_loader_->loadSynchronously(request, response, error, data);
66 } 66 }
67 67
68 void WebURLLoaderMock::loadAsynchronously(const WebKit::WebURLRequest& request, 68 void WebURLLoaderMock::loadAsynchronously(const blink::WebURLRequest& request,
69 WebKit::WebURLLoaderClient* client) { 69 blink::WebURLLoaderClient* client) {
70 if (factory_->IsMockedURL(request.url())) { 70 if (factory_->IsMockedURL(request.url())) {
71 client_ = client; 71 client_ = client;
72 factory_->LoadAsynchronouly(request, this); 72 factory_->LoadAsynchronouly(request, this);
73 return; 73 return;
74 } 74 }
75 DCHECK(static_cast<const GURL&>(request.url()).SchemeIs("data")) 75 DCHECK(static_cast<const GURL&>(request.url()).SchemeIs("data"))
76 << "loadAsynchronously shouldn't be falling back: " 76 << "loadAsynchronously shouldn't be falling back: "
77 << request.url().spec().data(); 77 << request.url().spec().data();
78 using_default_loader_ = true; 78 using_default_loader_ = true;
79 default_loader_->loadAsynchronously(request, client); 79 default_loader_->loadAsynchronously(request, client);
80 } 80 }
81 81
82 void WebURLLoaderMock::cancel() { 82 void WebURLLoaderMock::cancel() {
83 if (using_default_loader_) { 83 if (using_default_loader_) {
84 default_loader_->cancel(); 84 default_loader_->cancel();
85 return; 85 return;
86 } 86 }
87 client_ = NULL; 87 client_ = NULL;
88 factory_->CancelLoad(this); 88 factory_->CancelLoad(this);
89 } 89 }
90 90
91 void WebURLLoaderMock::setDefersLoading(bool deferred) { 91 void WebURLLoaderMock::setDefersLoading(bool deferred) {
92 is_deferred_ = deferred; 92 is_deferred_ = deferred;
93 if (using_default_loader_) { 93 if (using_default_loader_) {
94 default_loader_->setDefersLoading(deferred); 94 default_loader_->setDefersLoading(deferred);
95 return; 95 return;
96 } 96 }
97 NOTIMPLEMENTED(); 97 NOTIMPLEMENTED();
98 } 98 }
OLDNEW
« no previous file with comments | « content/test/weburl_loader_mock.h ('k') | content/test/weburl_loader_mock_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698