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/file_util.h" | 6 #include "base/file_util.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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 base::FilePath temp_path; | 78 base::FilePath temp_path; |
79 | 79 |
80 CreateAndRegisterTemporaryFile(&temp_url, &temp_path); | 80 CreateAndRegisterTemporaryFile(&temp_url, &temp_path); |
81 | 81 |
82 base::PlatformFileError error; | 82 base::PlatformFileError error; |
83 base::PlatformFileInfo file_info; | 83 base::PlatformFileInfo file_info; |
84 base::FilePath path; | 84 base::FilePath path; |
85 | 85 |
86 // Make sure the file is there. | 86 // Make sure the file is there. |
87 ASSERT_TRUE(temp_url.is_valid()); | 87 ASSERT_TRUE(temp_url.is_valid()); |
88 ASSERT_TRUE(file_util::PathExists(temp_path)); | 88 ASSERT_TRUE(base::PathExists(temp_path)); |
89 ASSERT_FALSE(file_util::DirectoryExists(temp_path)); | 89 ASSERT_FALSE(file_util::DirectoryExists(temp_path)); |
90 | 90 |
91 // Create a snapshot file. | 91 // Create a snapshot file. |
92 { | 92 { |
93 webkit_blob::ScopedFile scoped_file = | 93 webkit_blob::ScopedFile scoped_file = |
94 file_util()->CreateSnapshotFile(NewOperationContext().get(), | 94 file_util()->CreateSnapshotFile(NewOperationContext().get(), |
95 temp_url, | 95 temp_url, |
96 &error, | 96 &error, |
97 &file_info, | 97 &file_info, |
98 &path); | 98 &path); |
99 ASSERT_EQ(base::PLATFORM_FILE_OK, error); | 99 ASSERT_EQ(base::PLATFORM_FILE_OK, error); |
100 ASSERT_EQ(temp_path, path); | 100 ASSERT_EQ(temp_path, path); |
101 ASSERT_FALSE(file_info.is_directory); | 101 ASSERT_FALSE(file_info.is_directory); |
102 | 102 |
103 // The file should be still there. | 103 // The file should be still there. |
104 ASSERT_TRUE(file_util::PathExists(temp_path)); | 104 ASSERT_TRUE(base::PathExists(temp_path)); |
105 ASSERT_EQ(base::PLATFORM_FILE_OK, | 105 ASSERT_EQ(base::PLATFORM_FILE_OK, |
106 file_util()->GetFileInfo(NewOperationContext().get(), | 106 file_util()->GetFileInfo(NewOperationContext().get(), |
107 temp_url, &file_info, &path)); | 107 temp_url, &file_info, &path)); |
108 ASSERT_EQ(temp_path, path); | 108 ASSERT_EQ(temp_path, path); |
109 ASSERT_FALSE(file_info.is_directory); | 109 ASSERT_FALSE(file_info.is_directory); |
110 } | 110 } |
111 | 111 |
112 // The file's now scoped out. | 112 // The file's now scoped out. |
113 base::MessageLoop::current()->RunUntilIdle(); | 113 base::MessageLoop::current()->RunUntilIdle(); |
114 | 114 |
115 // Now the temporary file and the transient filesystem must be gone too. | 115 // Now the temporary file and the transient filesystem must be gone too. |
116 ASSERT_FALSE(file_util::PathExists(temp_path)); | 116 ASSERT_FALSE(base::PathExists(temp_path)); |
117 ASSERT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, | 117 ASSERT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, |
118 file_util()->GetFileInfo(NewOperationContext().get(), | 118 file_util()->GetFileInfo(NewOperationContext().get(), |
119 temp_url, &file_info, &path)); | 119 temp_url, &file_info, &path)); |
120 } | 120 } |
121 | 121 |
122 } // namespace fileapi | 122 } // namespace fileapi |
OLD | NEW |