| OLD | NEW |
| 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 "chrome/browser/chromeos/drive/file_system_util.h" | 5 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/message_loop_proxy.h" | 14 #include "base/message_loop_proxy.h" |
| 15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 16 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
| 17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 18 #include "chrome/browser/chromeos/drive/drive.pb.h" | 18 #include "chrome/browser/chromeos/drive/drive.pb.h" |
| 19 #include "chrome/browser/chromeos/drive/drive_system_service.h" | 19 #include "chrome/browser/chromeos/drive/drive_system_service.h" |
| 20 #include "chrome/browser/chromeos/drive/file_system_interface.h" | 20 #include "chrome/browser/chromeos/drive/file_system_interface.h" |
| 21 #include "chrome/browser/chromeos/drive/file_write_helper.h" | 21 #include "chrome/browser/chromeos/drive/file_write_helper.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/common/chrome_constants.h" | 23 #include "chrome/common/chrome_constants.h" |
| 24 #include "chrome/common/chrome_paths_internal.h" | 24 #include "chrome/common/chrome_paths_internal.h" |
| 25 #include "chrome/common/url_constants.h" | 25 #include "chrome/common/url_constants.h" |
| 26 #include "chromeos/chromeos_constants.h" | |
| 27 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
| 28 #include "net/base/escape.h" | 27 #include "net/base/escape.h" |
| 29 #include "webkit/fileapi/file_system_url.h" | 28 #include "webkit/fileapi/file_system_url.h" |
| 30 | 29 |
| 31 using content::BrowserThread; | 30 using content::BrowserThread; |
| 32 | 31 |
| 33 namespace drive { | 32 namespace drive { |
| 34 namespace util { | 33 namespace util { |
| 35 | 34 |
| 36 namespace { | 35 namespace { |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 const fileapi::FileSystemURL& url) { | 215 const fileapi::FileSystemURL& url) { |
| 217 if (!url.is_valid() || url.type() != fileapi::kFileSystemTypeDrive) | 216 if (!url.is_valid() || url.type() != fileapi::kFileSystemTypeDrive) |
| 218 return base::FilePath(); | 217 return base::FilePath(); |
| 219 return ExtractDrivePath(url.path()); | 218 return ExtractDrivePath(url.path()); |
| 220 } | 219 } |
| 221 | 220 |
| 222 base::FilePath GetCacheRootPath(Profile* profile) { | 221 base::FilePath GetCacheRootPath(Profile* profile) { |
| 223 base::FilePath cache_base_path; | 222 base::FilePath cache_base_path; |
| 224 chrome::GetUserCacheDirectory(profile->GetPath(), &cache_base_path); | 223 chrome::GetUserCacheDirectory(profile->GetPath(), &cache_base_path); |
| 225 base::FilePath cache_root_path = | 224 base::FilePath cache_root_path = |
| 226 cache_base_path.Append(chromeos::kDriveCacheDirname); | 225 cache_base_path.Append(chrome::kDriveCacheDirname); |
| 227 return cache_root_path.Append(kFileCacheVersionDir); | 226 return cache_root_path.Append(kFileCacheVersionDir); |
| 228 } | 227 } |
| 229 | 228 |
| 230 std::string EscapeCacheFileName(const std::string& filename) { | 229 std::string EscapeCacheFileName(const std::string& filename) { |
| 231 // This is based on net/base/escape.cc: net::(anonymous namespace)::Escape | 230 // This is based on net/base/escape.cc: net::(anonymous namespace)::Escape |
| 232 std::string escaped; | 231 std::string escaped; |
| 233 for (size_t i = 0; i < filename.size(); ++i) { | 232 for (size_t i = 0; i < filename.size(); ++i) { |
| 234 char c = filename[i]; | 233 char c = filename[i]; |
| 235 if (c == '%' || c == '.' || c == '/') { | 234 if (c == '%' || c == '.' || c == '/') { |
| 236 base::StringAppendF(&escaped, "%%%02X", c); | 235 base::StringAppendF(&escaped, "%%%02X", c); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 entry->set_last_modified(file_info.last_modified.ToInternalValue()); | 386 entry->set_last_modified(file_info.last_modified.ToInternalValue()); |
| 388 entry->set_last_accessed(file_info.last_accessed.ToInternalValue()); | 387 entry->set_last_accessed(file_info.last_accessed.ToInternalValue()); |
| 389 entry->set_creation_time(file_info.creation_time.ToInternalValue()); | 388 entry->set_creation_time(file_info.creation_time.ToInternalValue()); |
| 390 } | 389 } |
| 391 | 390 |
| 392 void EmptyFileOperationCallback(FileError error) { | 391 void EmptyFileOperationCallback(FileError error) { |
| 393 } | 392 } |
| 394 | 393 |
| 395 } // namespace util | 394 } // namespace util |
| 396 } // namespace drive | 395 } // namespace drive |
| OLD | NEW |