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

Side by Side Diff: content/test/net/url_request_mock_http_job.cc

Issue 10700117: Replaced static URLRequestFileJob factory with non-static protocol handler for File jobs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed nits Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/chrome_url_data_manager_backend.cc ('k') | net/net.gyp » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/net/url_request_mock_http_job.h" 5 #include "content/test/net/url_request_mock_http_job.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "content/public/common/url_constants.h" 12 #include "content/public/common/url_constants.h"
13 #include "net/base/net_util.h" 13 #include "net/base/net_util.h"
14 #include "net/http/http_response_headers.h" 14 #include "net/http/http_response_headers.h"
15 #include "net/url_request/url_request_context.h"
15 #include "net/url_request/url_request_filter.h" 16 #include "net/url_request/url_request_filter.h"
16 17
17 const char kMockHostname[] = "mock.http"; 18 const char kMockHostname[] = "mock.http";
18 const FilePath::CharType kMockHeaderFileSuffix[] = 19 const FilePath::CharType kMockHeaderFileSuffix[] =
19 FILE_PATH_LITERAL(".mock-http-headers"); 20 FILE_PATH_LITERAL(".mock-http-headers");
20 21
21 namespace { 22 namespace {
22 23
23 // This is the file path leading to the root of the directory to use as the 24 // This is the file path leading to the root of the directory to use as the
24 // root of the http server. This returns a reference that can be assigned to. 25 // root of the http server. This returns a reference that can be assigned to.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 // path to that, and convert the final URL back to a FilePath. 76 // path to that, and convert the final URL back to a FilePath.
76 GURL file_url(net::FilePathToFileURL(base_path)); 77 GURL file_url(net::FilePathToFileURL(base_path));
77 std::string url = file_url.spec() + request->url().path(); 78 std::string url = file_url.spec() + request->url().path();
78 FilePath file_path; 79 FilePath file_path;
79 net::FileURLToFilePath(GURL(url), &file_path); 80 net::FileURLToFilePath(GURL(url), &file_path);
80 return file_path; 81 return file_path;
81 } 82 }
82 83
83 URLRequestMockHTTPJob::URLRequestMockHTTPJob(net::URLRequest* request, 84 URLRequestMockHTTPJob::URLRequestMockHTTPJob(net::URLRequest* request,
84 const FilePath& file_path) 85 const FilePath& file_path)
85 : net::URLRequestFileJob(request, file_path) { } 86 : net::URLRequestFileJob(request,
87 file_path,
88 request->context()->network_delegate()) { }
86 89
87 // Public virtual version. 90 // Public virtual version.
88 void URLRequestMockHTTPJob::GetResponseInfo(net::HttpResponseInfo* info) { 91 void URLRequestMockHTTPJob::GetResponseInfo(net::HttpResponseInfo* info) {
89 // Forward to private const version. 92 // Forward to private const version.
90 GetResponseInfoConst(info); 93 GetResponseInfoConst(info);
91 } 94 }
92 95
93 bool URLRequestMockHTTPJob::IsRedirectResponse(GURL* location, 96 bool URLRequestMockHTTPJob::IsRedirectResponse(GURL* location,
94 int* http_status_code) { 97 int* http_status_code) {
95 // Override the net::URLRequestFileJob implementation to invoke the default 98 // Override the net::URLRequestFileJob implementation to invoke the default
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 if (info.headers) 130 if (info.headers)
128 return info.headers->response_code(); 131 return info.headers->response_code();
129 return net::URLRequestJob::GetResponseCode(); 132 return net::URLRequestJob::GetResponseCode();
130 } 133 }
131 134
132 bool URLRequestMockHTTPJob::GetCharset(std::string* charset) { 135 bool URLRequestMockHTTPJob::GetCharset(std::string* charset) {
133 net::HttpResponseInfo info; 136 net::HttpResponseInfo info;
134 GetResponseInfo(&info); 137 GetResponseInfo(&info);
135 return info.headers && info.headers->GetCharset(charset); 138 return info.headers && info.headers->GetCharset(charset);
136 } 139 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/chrome_url_data_manager_backend.cc ('k') | net/net.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698