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

Side by Side Diff: webkit/fileapi/file_system_dir_url_request_job_unittest.cc

Issue 10855209: Refactoring: ProtocolHandler::MaybeCreateJob takes NetworkDelegate as argument (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Latest merge 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
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 "webkit/fileapi/file_system_dir_url_request_job.h" 5 #include "webkit/fileapi/file_system_dir_url_request_job.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/format_macros.h" 10 #include "base/format_macros.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/platform_file.h" 13 #include "base/platform_file.h"
14 #include "base/scoped_temp_dir.h" 14 #include "base/scoped_temp_dir.h"
15 #include "base/string_piece.h" 15 #include "base/string_piece.h"
16 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
17 #include "net/base/net_errors.h" 17 #include "net/base/net_errors.h"
18 #include "net/base/net_util.h" 18 #include "net/base/net_util.h"
19 #include "net/http/http_request_headers.h" 19 #include "net/http/http_request_headers.h"
20 #include "net/url_request/url_request.h" 20 #include "net/url_request/url_request.h"
21 #include "net/url_request/url_request_context.h"
21 #include "net/url_request/url_request_test_util.h" 22 #include "net/url_request/url_request_test_util.h"
22 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
23 #include "unicode/regex.h" 24 #include "unicode/regex.h"
24 #include "webkit/fileapi/file_system_context.h" 25 #include "webkit/fileapi/file_system_context.h"
25 #include "webkit/fileapi/file_system_file_util.h" 26 #include "webkit/fileapi/file_system_file_util.h"
26 #include "webkit/fileapi/file_system_operation_context.h" 27 #include "webkit/fileapi/file_system_operation_context.h"
27 #include "webkit/fileapi/file_system_task_runners.h" 28 #include "webkit/fileapi/file_system_task_runners.h"
28 #include "webkit/fileapi/file_system_url.h" 29 #include "webkit/fileapi/file_system_url.h"
29 #include "webkit/fileapi/mock_file_system_options.h" 30 #include "webkit/fileapi/mock_file_system_options.h"
30 #include "webkit/fileapi/sandbox_mount_point_provider.h" 31 #include "webkit/fileapi/sandbox_mount_point_provider.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 void OnValidateFileSystem(base::PlatformFileError result) { 80 void OnValidateFileSystem(base::PlatformFileError result) {
80 ASSERT_EQ(base::PLATFORM_FILE_OK, result); 81 ASSERT_EQ(base::PLATFORM_FILE_OK, result);
81 } 82 }
82 83
83 void TestRequestHelper(const GURL& url, bool run_to_completion) { 84 void TestRequestHelper(const GURL& url, bool run_to_completion) {
84 delegate_.reset(new TestDelegate()); 85 delegate_.reset(new TestDelegate());
85 delegate_->set_quit_on_redirect(true); 86 delegate_->set_quit_on_redirect(true);
86 request_.reset(new net::URLRequest(url, 87 request_.reset(new net::URLRequest(url,
87 delegate_.get(), 88 delegate_.get(),
88 &empty_context_)); 89 &empty_context_));
89 job_ = new FileSystemDirURLRequestJob(request_.get(), 90 job_ = new FileSystemDirURLRequestJob(
90 file_system_context_.get()); 91 request_.get(),
92 empty_context_.network_delegate(),
93 file_system_context_.get());
91 94
92 request_->Start(); 95 request_->Start();
93 ASSERT_TRUE(request_->is_pending()); // verify that we're starting async 96 ASSERT_TRUE(request_->is_pending()); // verify that we're starting async
94 if (run_to_completion) 97 if (run_to_completion)
95 MessageLoop::current()->Run(); 98 MessageLoop::current()->Run();
96 } 99 }
97 100
98 void TestRequest(const GURL& url) { 101 void TestRequest(const GURL& url) {
99 TestRequestHelper(url, true); 102 TestRequestHelper(url, true);
100 } 103 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 EXPECT_TRUE(base::Time::FromString(date_str.c_str(), &date)); 182 EXPECT_TRUE(base::Time::FromString(date_str.c_str(), &date));
180 EXPECT_FALSE(date.is_null()); 183 EXPECT_FALSE(date.is_null());
181 } 184 }
182 185
183 GURL CreateFileSystemURL(const std::string path) { 186 GURL CreateFileSystemURL(const std::string path) {
184 return GURL(kFileSystemURLPrefix + path); 187 return GURL(kFileSystemURLPrefix + path);
185 } 188 }
186 189
187 static net::URLRequestJob* FileSystemDirURLRequestJobFactory( 190 static net::URLRequestJob* FileSystemDirURLRequestJobFactory(
188 net::URLRequest* request, 191 net::URLRequest* request,
192 net::NetworkDelegate* network_delegate,
189 const std::string& scheme) { 193 const std::string& scheme) {
190 DCHECK(job_); 194 DCHECK(job_);
191 net::URLRequestJob* temp = job_; 195 net::URLRequestJob* temp = job_;
192 job_ = NULL; 196 job_ = NULL;
193 return temp; 197 return temp;
194 } 198 }
195 199
196 static void ClearUnusedJob() { 200 static void ClearUnusedJob() {
197 if (job_) { 201 if (job_) {
198 scoped_refptr<net::URLRequestJob> deleter = job_; 202 scoped_refptr<net::URLRequestJob> deleter = job_;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 CreateDirectory("foo"); 288 CreateDirectory("foo");
285 TestRequestNoRun(CreateFileSystemURL("foo/")); 289 TestRequestNoRun(CreateFileSystemURL("foo/"));
286 // Run StartAsync() and only StartAsync(). 290 // Run StartAsync() and only StartAsync().
287 MessageLoop::current()->DeleteSoon(FROM_HERE, request_.release()); 291 MessageLoop::current()->DeleteSoon(FROM_HERE, request_.release());
288 MessageLoop::current()->RunAllPending(); 292 MessageLoop::current()->RunAllPending();
289 // If we get here, success! we didn't crash! 293 // If we get here, success! we didn't crash!
290 } 294 }
291 295
292 } // namespace (anonymous) 296 } // namespace (anonymous)
293 } // namespace fileapi 297 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_dir_url_request_job.cc ('k') | webkit/fileapi/file_system_url_request_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698