| OLD | NEW |
| 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 171 |
| 172 class TestCopyOrMoveFileValidatorFactory | 172 class TestCopyOrMoveFileValidatorFactory |
| 173 : public CopyOrMoveFileValidatorFactory { | 173 : public CopyOrMoveFileValidatorFactory { |
| 174 public: | 174 public: |
| 175 // A factory that creates validators that accept everything or nothing. | 175 // A factory that creates validators that accept everything or nothing. |
| 176 TestCopyOrMoveFileValidatorFactory(bool all_valid) : all_valid_(all_valid) {} | 176 TestCopyOrMoveFileValidatorFactory(bool all_valid) : all_valid_(all_valid) {} |
| 177 virtual ~TestCopyOrMoveFileValidatorFactory() {} | 177 virtual ~TestCopyOrMoveFileValidatorFactory() {} |
| 178 | 178 |
| 179 virtual CopyOrMoveFileValidator* CreateCopyOrMoveFileValidator( | 179 virtual CopyOrMoveFileValidator* CreateCopyOrMoveFileValidator( |
| 180 const FileSystemURL& /*src_url*/, | 180 const FileSystemURL& /*src_url*/, |
| 181 const base::FilePath& /*platform_path*/) { | 181 const base::FilePath& /*platform_path*/) OVERRIDE { |
| 182 return new TestCopyOrMoveFileValidator(all_valid_); | 182 return new TestCopyOrMoveFileValidator(all_valid_); |
| 183 } | 183 } |
| 184 | 184 |
| 185 private: | 185 private: |
| 186 class TestCopyOrMoveFileValidator : public CopyOrMoveFileValidator { | 186 class TestCopyOrMoveFileValidator : public CopyOrMoveFileValidator { |
| 187 public: | 187 public: |
| 188 TestCopyOrMoveFileValidator(bool all_valid) | 188 TestCopyOrMoveFileValidator(bool all_valid) |
| 189 : result_(all_valid ? base::PLATFORM_FILE_OK | 189 : result_(all_valid ? base::PLATFORM_FILE_OK |
| 190 : base::PLATFORM_FILE_ERROR_SECURITY) { | 190 : base::PLATFORM_FILE_ERROR_SECURITY) { |
| 191 } | 191 } |
| 192 virtual ~TestCopyOrMoveFileValidator() {} | 192 virtual ~TestCopyOrMoveFileValidator() {} |
| 193 | 193 |
| 194 virtual void StartValidation(const ResultCallback& result_callback) { | 194 virtual void StartValidation( |
| 195 const ResultCallback& result_callback) OVERRIDE { |
| 195 // Post the result since a real validator must do work asynchronously. | 196 // Post the result since a real validator must do work asynchronously. |
| 196 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(result_callback, | 197 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(result_callback, |
| 197 result_)); | 198 result_)); |
| 198 } | 199 } |
| 199 | 200 |
| 200 private: | 201 private: |
| 201 base::PlatformFileError result_; | 202 base::PlatformFileError result_; |
| 202 | 203 |
| 203 DISALLOW_COPY_AND_ASSIGN(TestCopyOrMoveFileValidator); | 204 DISALLOW_COPY_AND_ASSIGN(TestCopyOrMoveFileValidator); |
| 204 }; | 205 }; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 | 271 |
| 271 scoped_ptr<CopyOrMoveFileValidatorFactory> accept_factory( | 272 scoped_ptr<CopyOrMoveFileValidatorFactory> accept_factory( |
| 272 new TestCopyOrMoveFileValidatorFactory(true /*accept_all*/)); | 273 new TestCopyOrMoveFileValidatorFactory(true /*accept_all*/)); |
| 273 helper.SetMediaCopyOrMoveFileValidatorFactory(accept_factory.Pass()); | 274 helper.SetMediaCopyOrMoveFileValidatorFactory(accept_factory.Pass()); |
| 274 | 275 |
| 275 helper.CopyTest(base::PLATFORM_FILE_ERROR_SECURITY); | 276 helper.CopyTest(base::PLATFORM_FILE_ERROR_SECURITY); |
| 276 helper.MoveTest(base::PLATFORM_FILE_ERROR_SECURITY); | 277 helper.MoveTest(base::PLATFORM_FILE_ERROR_SECURITY); |
| 277 } | 278 } |
| 278 | 279 |
| 279 } // namespace fileapi | 280 } // namespace fileapi |
| OLD | NEW |