Vibration API: convert implementation to java mojo-service.
[chromium-blink-merge.git] / content / test / test_navigation_url_loader.cc
blobd054dc35faabe4639b6c5a5e405259e6c6549cfc
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/test/test_navigation_url_loader.h"
7 #include "content/browser/loader/navigation_url_loader_delegate.h"
8 #include "content/public/browser/stream_handle.h"
9 #include "content/public/common/resource_response.h"
10 #include "net/url_request/redirect_info.h"
12 namespace content {
14 TestNavigationURLLoader::TestNavigationURLLoader(
15 scoped_ptr<NavigationRequestInfo> request_info,
16 NavigationURLLoaderDelegate* delegate)
17 : request_info_(request_info.Pass()),
18 delegate_(delegate),
19 redirect_count_(0) {
22 void TestNavigationURLLoader::FollowRedirect() {
23 redirect_count_++;
26 void TestNavigationURLLoader::SimulateServerRedirect(const GURL& redirect_url) {
27 net::RedirectInfo redirect_info;
28 redirect_info.status_code = 302;
29 redirect_info.new_method = "GET";
30 redirect_info.new_url = redirect_url;
31 redirect_info.new_first_party_for_cookies = redirect_url;
32 scoped_refptr<ResourceResponse> response(new ResourceResponse);
33 CallOnRequestRedirected(redirect_info, response);
36 void TestNavigationURLLoader::SimulateError(int error_code) {
37 delegate_->OnRequestFailed(false, error_code);
40 void TestNavigationURLLoader::CallOnRequestRedirected(
41 const net::RedirectInfo& redirect_info,
42 const scoped_refptr<ResourceResponse>& response) {
43 delegate_->OnRequestRedirected(redirect_info, response);
46 void TestNavigationURLLoader::CallOnResponseStarted(
47 const scoped_refptr<ResourceResponse>& response,
48 scoped_ptr<StreamHandle> body) {
49 delegate_->OnResponseStarted(response, body.Pass());
52 TestNavigationURLLoader::~TestNavigationURLLoader() {}
54 } // namespace content