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

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

Issue 10829147: Make MediaFileUtil run on thread pool. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: build fix for windows 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 | « webkit/fileapi/file_system_context.cc ('k') | webkit/fileapi/file_system_file_stream_reader.cc » ('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 "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_test_util.h" 21 #include "net/url_request/url_request_test_util.h"
22 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
23 #include "unicode/regex.h" 23 #include "unicode/regex.h"
24 #include "webkit/fileapi/file_system_context.h" 24 #include "webkit/fileapi/file_system_context.h"
25 #include "webkit/fileapi/file_system_file_util.h" 25 #include "webkit/fileapi/file_system_file_util.h"
26 #include "webkit/fileapi/file_system_operation_context.h" 26 #include "webkit/fileapi/file_system_operation_context.h"
27 #include "webkit/fileapi/file_system_task_runners.h"
27 #include "webkit/fileapi/file_system_url.h" 28 #include "webkit/fileapi/file_system_url.h"
28 #include "webkit/fileapi/mock_file_system_options.h" 29 #include "webkit/fileapi/mock_file_system_options.h"
29 #include "webkit/fileapi/sandbox_mount_point_provider.h" 30 #include "webkit/fileapi/sandbox_mount_point_provider.h"
30 #include "webkit/quota/mock_special_storage_policy.h" 31 #include "webkit/quota/mock_special_storage_policy.h"
31 32
32 namespace fileapi { 33 namespace fileapi {
33 namespace { 34 namespace {
34 35
35 // We always use the TEMPORARY FileSystem in this test. 36 // We always use the TEMPORARY FileSystem in this test.
36 static const char kFileSystemURLPrefix[] = 37 static const char kFileSystemURLPrefix[] =
37 "filesystem:http://remote/temporary/"; 38 "filesystem:http://remote/temporary/";
38 39
39 } // namespace 40 } // namespace
40 41
41 class FileSystemDirURLRequestJobTest : public testing::Test { 42 class FileSystemDirURLRequestJobTest : public testing::Test {
42 protected: 43 protected:
43 FileSystemDirURLRequestJobTest() 44 FileSystemDirURLRequestJobTest()
44 : message_loop_(MessageLoop::TYPE_IO), // simulate an IO thread 45 : message_loop_(MessageLoop::TYPE_IO), // simulate an IO thread
45 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { 46 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
46 } 47 }
47 48
48 virtual void SetUp() OVERRIDE { 49 virtual void SetUp() OVERRIDE {
49 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 50 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
50 51
51 file_thread_proxy_ = base::MessageLoopProxy::current();
52
53 special_storage_policy_ = new quota::MockSpecialStoragePolicy; 52 special_storage_policy_ = new quota::MockSpecialStoragePolicy;
54 file_system_context_ = 53 file_system_context_ =
55 new FileSystemContext( 54 new FileSystemContext(
56 file_thread_proxy_, 55 FileSystemTaskRunners::CreateMockTaskRunners(),
57 base::MessageLoopProxy::current(),
58 special_storage_policy_, NULL, 56 special_storage_policy_, NULL,
59 temp_dir_.path(), 57 temp_dir_.path(),
60 CreateAllowFileAccessOptions()); 58 CreateAllowFileAccessOptions());
61 59
62 file_system_context_->sandbox_provider()->ValidateFileSystemRoot( 60 file_system_context_->sandbox_provider()->ValidateFileSystemRoot(
63 GURL("http://remote/"), kFileSystemTypeTemporary, true, // create 61 GURL("http://remote/"), kFileSystemTypeTemporary, true, // create
64 base::Bind(&FileSystemDirURLRequestJobTest::OnValidateFileSystem, 62 base::Bind(&FileSystemDirURLRequestJobTest::OnValidateFileSystem,
65 weak_factory_.GetWeakPtr())); 63 weak_factory_.GetWeakPtr()));
66 MessageLoop::current()->RunAllPending(); 64 MessageLoop::current()->RunAllPending();
67 65
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 job_ = NULL; 199 job_ = NULL;
202 } 200 }
203 } 201 }
204 202
205 FileSystemFileUtil* file_util() { 203 FileSystemFileUtil* file_util() {
206 return file_system_context_->sandbox_provider()->GetFileUtil( 204 return file_system_context_->sandbox_provider()->GetFileUtil(
207 kFileSystemTypeTemporary); 205 kFileSystemTypeTemporary);
208 } 206 }
209 207
210 // Put the message loop at the top, so that it's the last thing deleted. 208 // Put the message loop at the top, so that it's the last thing deleted.
211 MessageLoop message_loop_;
212 // Delete all MessageLoopProxy objects before the MessageLoop, to help prevent 209 // Delete all MessageLoopProxy objects before the MessageLoop, to help prevent
213 // leaks caused by tasks posted during shutdown. 210 // leaks caused by tasks posted during shutdown.
214 scoped_refptr<base::MessageLoopProxy> file_thread_proxy_; 211 MessageLoop message_loop_;
215 212
216 ScopedTempDir temp_dir_; 213 ScopedTempDir temp_dir_;
217 net::URLRequestContext empty_context_; 214 net::URLRequestContext empty_context_;
218 scoped_ptr<TestDelegate> delegate_; 215 scoped_ptr<TestDelegate> delegate_;
219 scoped_ptr<net::URLRequest> request_; 216 scoped_ptr<net::URLRequest> request_;
220 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy_; 217 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy_;
221 scoped_refptr<FileSystemContext> file_system_context_; 218 scoped_refptr<FileSystemContext> file_system_context_;
222 base::WeakPtrFactory<FileSystemDirURLRequestJobTest> weak_factory_; 219 base::WeakPtrFactory<FileSystemDirURLRequestJobTest> weak_factory_;
223 220
224 static net::URLRequestJob* job_; 221 static net::URLRequestJob* job_;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 CreateDirectory("foo"); 284 CreateDirectory("foo");
288 TestRequestNoRun(CreateFileSystemURL("foo/")); 285 TestRequestNoRun(CreateFileSystemURL("foo/"));
289 // Run StartAsync() and only StartAsync(). 286 // Run StartAsync() and only StartAsync().
290 MessageLoop::current()->DeleteSoon(FROM_HERE, request_.release()); 287 MessageLoop::current()->DeleteSoon(FROM_HERE, request_.release());
291 MessageLoop::current()->RunAllPending(); 288 MessageLoop::current()->RunAllPending();
292 // If we get here, success! we didn't crash! 289 // If we get here, success! we didn't crash!
293 } 290 }
294 291
295 } // namespace (anonymous) 292 } // namespace (anonymous)
296 } // namespace fileapi 293 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_context.cc ('k') | webkit/fileapi/file_system_file_stream_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698