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

Side by Side Diff: webkit/browser/fileapi/copy_or_move_file_validator_unittest.cc

Issue 18565002: [FileSystem] Add another copy-or-move validation hook for post-write. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Simplify dest validation callbacks and delete dest file on error Created 7 years, 5 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 187
188 virtual CopyOrMoveFileValidator* CreateCopyOrMoveFileValidator( 188 virtual CopyOrMoveFileValidator* CreateCopyOrMoveFileValidator(
189 const FileSystemURL& /*src_url*/, 189 const FileSystemURL& /*src_url*/,
190 const base::FilePath& /*platform_path*/) OVERRIDE { 190 const base::FilePath& /*platform_path*/) OVERRIDE {
191 return new TestCopyOrMoveFileValidator(all_valid_); 191 return new TestCopyOrMoveFileValidator(all_valid_);
192 } 192 }
193 193
194 private: 194 private:
195 class TestCopyOrMoveFileValidator : public CopyOrMoveFileValidator { 195 class TestCopyOrMoveFileValidator : public CopyOrMoveFileValidator {
196 public: 196 public:
197 explicit TestCopyOrMoveFileValidator(bool all_valid) 197 explicit TestCopyOrMoveFileValidator(bool all_valid)
vandebo (ex-Chrome) 2013/07/02 20:15:02 Looks like you need another parameter here and sev
Greg Billock 2013/07/03 16:08:27 Yes. I haven't added all that yet. Making sure thi
198 : result_(all_valid ? base::PLATFORM_FILE_OK 198 : result_(all_valid ? base::PLATFORM_FILE_OK
199 : base::PLATFORM_FILE_ERROR_SECURITY) { 199 : base::PLATFORM_FILE_ERROR_SECURITY),
200 write_result_(all_valid ? base::PLATFORM_FILE_OK
201 : base::PLATFORM_FILE_ERROR_SECURITY) {
200 } 202 }
201 virtual ~TestCopyOrMoveFileValidator() {} 203 virtual ~TestCopyOrMoveFileValidator() {}
202 204
203 virtual void StartValidation( 205 virtual void StartValidation(
204 const ResultCallback& result_callback) OVERRIDE { 206 const ResultCallback& result_callback) OVERRIDE {
205 // Post the result since a real validator must do work asynchronously. 207 // Post the result since a real validator must do work asynchronously.
206 base::MessageLoop::current()->PostTask( 208 base::MessageLoop::current()->PostTask(
207 FROM_HERE, base::Bind(result_callback, result_)); 209 FROM_HERE, base::Bind(result_callback, result_));
208 } 210 }
209 211
212 virtual void StartPostWriteValidation(
213 const base::FilePath& dest_platform_path,
214 const ResultCallback& result_callback) OVERRIDE {
215 // Post the result since a real validator must do work asynchronously.
216 base::MessageLoop::current()->PostTask(
217 FROM_HERE, base::Bind(result_callback, write_result_));
218 }
219
210 private: 220 private:
211 base::PlatformFileError result_; 221 base::PlatformFileError result_;
222 base::PlatformFileError write_result_;
212 223
213 DISALLOW_COPY_AND_ASSIGN(TestCopyOrMoveFileValidator); 224 DISALLOW_COPY_AND_ASSIGN(TestCopyOrMoveFileValidator);
214 }; 225 };
215 226
216 bool all_valid_; 227 bool all_valid_;
217 228
218 DISALLOW_COPY_AND_ASSIGN(TestCopyOrMoveFileValidatorFactory); 229 DISALLOW_COPY_AND_ASSIGN(TestCopyOrMoveFileValidatorFactory);
219 }; 230 };
220 231
221 } // namespace 232 } // namespace
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 291
281 scoped_ptr<CopyOrMoveFileValidatorFactory> accept_factory( 292 scoped_ptr<CopyOrMoveFileValidatorFactory> accept_factory(
282 new TestCopyOrMoveFileValidatorFactory(true /*accept_all*/)); 293 new TestCopyOrMoveFileValidatorFactory(true /*accept_all*/));
283 helper.SetMediaCopyOrMoveFileValidatorFactory(accept_factory.Pass()); 294 helper.SetMediaCopyOrMoveFileValidatorFactory(accept_factory.Pass());
284 295
285 helper.CopyTest(base::PLATFORM_FILE_ERROR_SECURITY); 296 helper.CopyTest(base::PLATFORM_FILE_ERROR_SECURITY);
286 helper.MoveTest(base::PLATFORM_FILE_ERROR_SECURITY); 297 helper.MoveTest(base::PLATFORM_FILE_ERROR_SECURITY);
287 } 298 }
288 299
289 } // namespace fileapi 300 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698