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

Side by Side Diff: content/browser/fileapi/file_system_dir_url_request_job_unittest.cc

Issue 145303002: Convert Media Galleries to use base::File (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/browser/fileapi/file_system_dir_url_request_job.h" 5 #include "webkit/browser/fileapi/file_system_dir_url_request_job.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // NOTE: order matters, request must die before delegate 72 // NOTE: order matters, request must die before delegate
73 request_.reset(NULL); 73 request_.reset(NULL);
74 delegate_.reset(NULL); 74 delegate_.reset(NULL);
75 75
76 net::URLRequest::Deprecated::RegisterProtocolFactory("filesystem", NULL); 76 net::URLRequest::Deprecated::RegisterProtocolFactory("filesystem", NULL);
77 ClearUnusedJob(); 77 ClearUnusedJob();
78 } 78 }
79 79
80 void OnOpenFileSystem(const GURL& root_url, 80 void OnOpenFileSystem(const GURL& root_url,
81 const std::string& name, 81 const std::string& name,
82 base::PlatformFileError result) { 82 base::File::Error result) {
83 ASSERT_EQ(base::PLATFORM_FILE_OK, result); 83 ASSERT_EQ(base::File::FILE_OK, result);
84 } 84 }
85 85
86 void TestRequestHelper(const GURL& url, bool run_to_completion, 86 void TestRequestHelper(const GURL& url, bool run_to_completion,
87 FileSystemContext* file_system_context) { 87 FileSystemContext* file_system_context) {
88 delegate_.reset(new net::TestDelegate()); 88 delegate_.reset(new net::TestDelegate());
89 delegate_->set_quit_on_redirect(true); 89 delegate_->set_quit_on_redirect(true);
90 request_ = empty_context_.CreateRequest( 90 request_ = empty_context_.CreateRequest(
91 url, net::DEFAULT_PRIORITY, delegate_.get()); 91 url, net::DEFAULT_PRIORITY, delegate_.get());
92 job_ = new fileapi::FileSystemDirURLRequestJob( 92 job_ = new fileapi::FileSystemDirURLRequestJob(
93 request_.get(), NULL, file_system_context); 93 request_.get(), NULL, file_system_context);
(...skipping 27 matching lines...) Expand all
121 FileSystemOperationContext* NewOperationContext() { 121 FileSystemOperationContext* NewOperationContext() {
122 FileSystemOperationContext* context( 122 FileSystemOperationContext* context(
123 new FileSystemOperationContext(file_system_context_.get())); 123 new FileSystemOperationContext(file_system_context_.get()));
124 context->set_allowed_bytes_growth(1024); 124 context->set_allowed_bytes_growth(1024);
125 return context; 125 return context;
126 } 126 }
127 127
128 void CreateDirectory(const base::StringPiece& dir_name) { 128 void CreateDirectory(const base::StringPiece& dir_name) {
129 base::FilePath path = base::FilePath().AppendASCII(dir_name); 129 base::FilePath path = base::FilePath().AppendASCII(dir_name);
130 scoped_ptr<FileSystemOperationContext> context(NewOperationContext()); 130 scoped_ptr<FileSystemOperationContext> context(NewOperationContext());
131 ASSERT_EQ(base::PLATFORM_FILE_OK, file_util()->CreateDirectory( 131 ASSERT_EQ(base::File::FILE_OK, file_util()->CreateDirectory(
132 context.get(), 132 context.get(),
133 CreateURL(path), 133 CreateURL(path),
134 false /* exclusive */, 134 false /* exclusive */,
135 false /* recursive */)); 135 false /* recursive */));
136 } 136 }
137 137
138 void EnsureFileExists(const base::StringPiece file_name) { 138 void EnsureFileExists(const base::StringPiece file_name) {
139 base::FilePath path = base::FilePath().AppendASCII(file_name); 139 base::FilePath path = base::FilePath().AppendASCII(file_name);
140 scoped_ptr<FileSystemOperationContext> context(NewOperationContext()); 140 scoped_ptr<FileSystemOperationContext> context(NewOperationContext());
141 ASSERT_EQ(base::PLATFORM_FILE_OK, file_util()->EnsureFileExists( 141 ASSERT_EQ(base::File::FILE_OK, file_util()->EnsureFileExists(
142 context.get(), CreateURL(path), NULL)); 142 context.get(), CreateURL(path), NULL));
143 } 143 }
144 144
145 void TruncateFile(const base::StringPiece file_name, int64 length) { 145 void TruncateFile(const base::StringPiece file_name, int64 length) {
146 base::FilePath path = base::FilePath().AppendASCII(file_name); 146 base::FilePath path = base::FilePath().AppendASCII(file_name);
147 scoped_ptr<FileSystemOperationContext> context(NewOperationContext()); 147 scoped_ptr<FileSystemOperationContext> context(NewOperationContext());
148 ASSERT_EQ(base::PLATFORM_FILE_OK, file_util()->Truncate( 148 ASSERT_EQ(base::File::FILE_OK, file_util()->Truncate(
149 context.get(), CreateURL(path), length)); 149 context.get(), CreateURL(path), length));
150 } 150 }
151 151
152 base::PlatformFileError GetFileInfo(const base::FilePath& path, 152 base::File::Error GetFileInfo(const base::FilePath& path,
153 base::PlatformFileInfo* file_info, 153 base::File::Info* file_info,
154 base::FilePath* platform_file_path) { 154 base::FilePath* platform_file_path) {
155 scoped_ptr<FileSystemOperationContext> context(NewOperationContext()); 155 scoped_ptr<FileSystemOperationContext> context(NewOperationContext());
156 return file_util()->GetFileInfo(context.get(), 156 return file_util()->GetFileInfo(context.get(),
157 CreateURL(path), 157 CreateURL(path),
158 file_info, platform_file_path); 158 file_info, platform_file_path);
159 } 159 }
160 160
161 void VerifyListingEntry(const std::string& entry_line, 161 void VerifyListingEntry(const std::string& entry_line,
162 const std::string& name, 162 const std::string& name,
163 const std::string& url, 163 const std::string& url,
164 bool is_directory, 164 bool is_directory,
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 316
317 TestRequestWithContext(CreateFileSystemURL("foo"), 317 TestRequestWithContext(CreateFileSystemURL("foo"),
318 file_system_context.get()); 318 file_system_context.get());
319 ASSERT_FALSE(request_->is_pending()); 319 ASSERT_FALSE(request_->is_pending());
320 ASSERT_FALSE(request_->status().is_success()); 320 ASSERT_FALSE(request_->status().is_success());
321 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error()); 321 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error());
322 } 322 }
323 323
324 } // namespace (anonymous) 324 } // namespace (anonymous)
325 } // namespace content 325 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698