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

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

Issue 11787028: New FileSystemURL cracking (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test on Win Created 7 years, 11 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 (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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/file_util.h" 7 #include "base/file_util.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 "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 *file_system_context_->GetUpdateObservers(type)); 126 *file_system_context_->GetUpdateObservers(type));
127 return context; 127 return context;
128 } 128 }
129 129
130 bool CreateFileSystemDirectory(const FilePath& file_path, 130 bool CreateFileSystemDirectory(const FilePath& file_path,
131 const std::string& origin_url, 131 const std::string& origin_url,
132 quota::StorageType storage_type) { 132 quota::StorageType storage_type) {
133 FileSystemType type = QuotaStorageTypeToFileSystemType(storage_type); 133 FileSystemType type = QuotaStorageTypeToFileSystemType(storage_type);
134 FileSystemFileUtil* file_util = file_system_context_->GetFileUtil(type); 134 FileSystemFileUtil* file_util = file_system_context_->GetFileUtil(type);
135 135
136 FileSystemURL url(GURL(origin_url), type, file_path); 136 FileSystemURL url = file_system_context_->CreateCrackedFileSystemURL(
137 GURL(origin_url), type, file_path);
137 scoped_ptr<FileSystemOperationContext> context( 138 scoped_ptr<FileSystemOperationContext> context(
138 CreateFileSystemOperationContext(type)); 139 CreateFileSystemOperationContext(type));
139 140
140 base::PlatformFileError result = 141 base::PlatformFileError result =
141 file_util->CreateDirectory(context.get(), url, false, false); 142 file_util->CreateDirectory(context.get(), url, false, false);
142 if (result != base::PLATFORM_FILE_OK) 143 if (result != base::PLATFORM_FILE_OK)
143 return false; 144 return false;
144 return true; 145 return true;
145 } 146 }
146 147
147 bool CreateFileSystemFile(const FilePath& file_path, 148 bool CreateFileSystemFile(const FilePath& file_path,
148 int64 file_size, 149 int64 file_size,
149 const std::string& origin_url, 150 const std::string& origin_url,
150 quota::StorageType storage_type) { 151 quota::StorageType storage_type) {
151 if (file_path.empty()) 152 if (file_path.empty())
152 return false; 153 return false;
153 154
154 FileSystemType type = QuotaStorageTypeToFileSystemType(storage_type); 155 FileSystemType type = QuotaStorageTypeToFileSystemType(storage_type);
155 FileSystemFileUtil* file_util = file_system_context_-> 156 FileSystemFileUtil* file_util = file_system_context_->
156 sandbox_provider()->GetFileUtil(type); 157 sandbox_provider()->GetFileUtil(type);
157 158
158 FileSystemURL url(GURL(origin_url), type, file_path); 159 FileSystemURL url = file_system_context_->CreateCrackedFileSystemURL(
160 GURL(origin_url), type, file_path);
159 scoped_ptr<FileSystemOperationContext> context( 161 scoped_ptr<FileSystemOperationContext> context(
160 CreateFileSystemOperationContext(type)); 162 CreateFileSystemOperationContext(type));
161 163
162 bool created = false; 164 bool created = false;
163 if (base::PLATFORM_FILE_OK != 165 if (base::PLATFORM_FILE_OK !=
164 file_util->EnsureFileExists(context.get(), url, &created)) 166 file_util->EnsureFileExists(context.get(), url, &created))
165 return false; 167 return false;
166 EXPECT_TRUE(created); 168 EXPECT_TRUE(created);
167 if (base::PLATFORM_FILE_OK != 169 if (base::PLATFORM_FILE_OK !=
168 file_util->Truncate(context.get(), url, file_size)) 170 file_util->Truncate(context.get(), url, file_size))
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 GetOriginUsage(quota_client.get(), 584 GetOriginUsage(quota_client.get(),
583 "https://bar.com/", 585 "https://bar.com/",
584 kPersistent)); 586 kPersistent));
585 EXPECT_EQ(64 + file_paths_cost_temporary_bar_https, 587 EXPECT_EQ(64 + file_paths_cost_temporary_bar_https,
586 GetOriginUsage(quota_client.get(), 588 GetOriginUsage(quota_client.get(),
587 "https://bar.com/", 589 "https://bar.com/",
588 kTemporary)); 590 kTemporary));
589 } 591 }
590 592
591 } // namespace fileapi 593 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_mount_point_provider_unittest.cc ('k') | webkit/fileapi/file_system_url.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698