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

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

Issue 9016020: Cleanup FileSystemOperation for preparing for adding FSO-factory method (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more cleanup around ValidateFileSystemRoot Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // NOTE: These tests are run as part of "unit_tests" (in chrome/test/unit) 5 // NOTE: These tests are run as part of "unit_tests" (in chrome/test/unit)
6 // rather than as part of test_shell_tests because they rely on being able 6 // rather than as part of test_shell_tests because they rely on being able
7 // to instantiate a MessageLoop of type TYPE_IO. test_shell_tests uses 7 // to instantiate a MessageLoop of type TYPE_IO. test_shell_tests uses
8 // TYPE_UI, which URLRequest doesn't allow. 8 // TYPE_UI, which URLRequest doesn't allow.
9 // 9 //
10 10
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 // We use the main thread so that we can get the root path synchronously. 79 // We use the main thread so that we can get the root path synchronously.
80 // TODO(adamk): Run this on the FILE thread we've created as well. 80 // TODO(adamk): Run this on the FILE thread we've created as well.
81 file_system_context_ = 81 file_system_context_ =
82 new FileSystemContext( 82 new FileSystemContext(
83 base::MessageLoopProxy::current(), 83 base::MessageLoopProxy::current(),
84 base::MessageLoopProxy::current(), 84 base::MessageLoopProxy::current(),
85 special_storage_policy_, NULL, 85 special_storage_policy_, NULL,
86 temp_dir_.path(), 86 temp_dir_.path(),
87 new MockFileSystemOptions()); 87 new MockFileSystemOptions());
88 88
89 file_system_context_->sandbox_provider()->ValidateFileSystemRootAndGetURL( 89 file_system_context_->sandbox_provider()->ValidateFileSystemRoot(
90 GURL("http://remote/"), kFileSystemTypeTemporary, true, // create 90 GURL("http://remote/"), kFileSystemTypeTemporary, true, // create
91 base::Bind(&FileSystemURLRequestJobTest::OnGetRootPath, 91 base::Bind(&FileSystemURLRequestJobTest::OnValidateFileSystem,
92 weak_factory_.GetWeakPtr())); 92 weak_factory_.GetWeakPtr()));
93 MessageLoop::current()->RunAllPending(); 93 MessageLoop::current()->RunAllPending();
94 94
95 net::URLRequest::Deprecated::RegisterProtocolFactory( 95 net::URLRequest::Deprecated::RegisterProtocolFactory(
96 "filesystem", &FileSystemURLRequestJobFactory); 96 "filesystem", &FileSystemURLRequestJobFactory);
97 } 97 }
98 98
99 virtual void TearDown() { 99 virtual void TearDown() {
100 net::URLRequest::Deprecated::RegisterProtocolFactory("filesystem", NULL); 100 net::URLRequest::Deprecated::RegisterProtocolFactory("filesystem", NULL);
101 } 101 }
102 102
103 void OnGetRootPath(bool success, const FilePath& root_path, 103 void OnValidateFileSystem(base::PlatformFileError result) {
104 const std::string& name) { 104 ASSERT_EQ(base::PLATFORM_FILE_OK, result);
105 ASSERT_TRUE(success);
106 origin_root_path_ = root_path;
107 } 105 }
108 106
109 void TestRequestHelper(const GURL& url, 107 void TestRequestHelper(const GURL& url,
110 const net::HttpRequestHeaders* headers, 108 const net::HttpRequestHeaders* headers,
111 bool run_to_completion) { 109 bool run_to_completion) {
112 delegate_.reset(new TestDelegate()); 110 delegate_.reset(new TestDelegate());
113 // Make delegate_ exit the MessageLoop when the request is done. 111 // Make delegate_ exit the MessageLoop when the request is done.
114 delegate_->set_quit_on_complete(true); 112 delegate_->set_quit_on_complete(true);
115 delegate_->set_quit_on_redirect(true); 113 delegate_->set_quit_on_redirect(true);
116 request_.reset(new net::URLRequest(url, delegate_.get())); 114 request_.reset(new net::URLRequest(url, delegate_.get()));
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 DCHECK(job_); 189 DCHECK(job_);
192 net::URLRequestJob* temp = job_; 190 net::URLRequestJob* temp = job_;
193 job_ = NULL; 191 job_ = NULL;
194 return temp; 192 return temp;
195 } 193 }
196 194
197 // Put the message loop at the top, so that it's the last thing deleted. 195 // Put the message loop at the top, so that it's the last thing deleted.
198 MessageLoop message_loop_; 196 MessageLoop message_loop_;
199 197
200 ScopedTempDir temp_dir_; 198 ScopedTempDir temp_dir_;
201 FilePath origin_root_path_;
202 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy_; 199 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy_;
203 scoped_refptr<FileSystemContext> file_system_context_; 200 scoped_refptr<FileSystemContext> file_system_context_;
204 base::WeakPtrFactory<FileSystemURLRequestJobTest> weak_factory_; 201 base::WeakPtrFactory<FileSystemURLRequestJobTest> weak_factory_;
205 202
206 // NOTE: order matters, request must die before delegate 203 // NOTE: order matters, request must die before delegate
207 scoped_ptr<TestDelegate> delegate_; 204 scoped_ptr<TestDelegate> delegate_;
208 scoped_ptr<net::URLRequest> request_; 205 scoped_ptr<net::URLRequest> request_;
209 206
210 static net::URLRequestJob* job_; 207 static net::URLRequestJob* job_;
211 }; 208 };
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 363
367 TestRequest(CreateFileSystemURL(kFilename)); 364 TestRequest(CreateFileSystemURL(kFilename));
368 365
369 std::string mime_type_from_job; 366 std::string mime_type_from_job;
370 request_->GetMimeType(&mime_type_from_job); 367 request_->GetMimeType(&mime_type_from_job);
371 EXPECT_EQ(mime_type_direct, mime_type_from_job); 368 EXPECT_EQ(mime_type_direct, mime_type_from_job);
372 } 369 }
373 370
374 } // namespace (anonymous) 371 } // namespace (anonymous)
375 } // namespace fileapi 372 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698