| 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/gdata/gdata_file_system.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_file_system.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 #include "net/url_request/url_request_filter.h" | 47 #include "net/url_request/url_request_filter.h" |
| 48 | 48 |
| 49 using content::BrowserThread; | 49 using content::BrowserThread; |
| 50 | 50 |
| 51 namespace gdata { | 51 namespace gdata { |
| 52 namespace { | 52 namespace { |
| 53 | 53 |
| 54 const char kMimeTypeJson[] = "application/json"; | 54 const char kMimeTypeJson[] = "application/json"; |
| 55 const char kMimeTypeOctetStream[] = "application/octet-stream"; | 55 const char kMimeTypeOctetStream[] = "application/octet-stream"; |
| 56 | 56 |
| 57 const FilePath::CharType kGDataRootDirectory[] = FILE_PATH_LITERAL("gdata"); | |
| 58 const char kWildCard[] = "*"; | 57 const char kWildCard[] = "*"; |
| 59 const char kLocallyModifiedFileExtension[] = "local"; | 58 const char kLocallyModifiedFileExtension[] = "local"; |
| 60 const char kMountedArchiveFileExtension[] = "mounted"; | 59 const char kMountedArchiveFileExtension[] = "mounted"; |
| 61 | 60 |
| 62 const FilePath::CharType kGDataCacheVersionDir[] = FILE_PATH_LITERAL("v1"); | 61 const FilePath::CharType kGDataCacheVersionDir[] = FILE_PATH_LITERAL("v1"); |
| 63 const FilePath::CharType kGDataCacheMetaDir[] = FILE_PATH_LITERAL("meta"); | 62 const FilePath::CharType kGDataCacheMetaDir[] = FILE_PATH_LITERAL("meta"); |
| 64 const FilePath::CharType kGDataCachePinnedDir[] = FILE_PATH_LITERAL("pinned"); | 63 const FilePath::CharType kGDataCachePinnedDir[] = FILE_PATH_LITERAL("pinned"); |
| 65 const FilePath::CharType kGDataCacheOutgoingDir[] = | 64 const FilePath::CharType kGDataCacheOutgoingDir[] = |
| 66 FILE_PATH_LITERAL("outgoing"); | 65 FILE_PATH_LITERAL("outgoing"); |
| 67 const FilePath::CharType kGDataCachePersistentDir[] = | 66 const FilePath::CharType kGDataCachePersistentDir[] = |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 } | 408 } |
| 410 } | 409 } |
| 411 | 410 |
| 412 // Recursively extracts the paths set of all sub-directories of |entry|. | 411 // Recursively extracts the paths set of all sub-directories of |entry|. |
| 413 void GetChildDirectoryPaths(GDataEntry* entry, | 412 void GetChildDirectoryPaths(GDataEntry* entry, |
| 414 std::set<FilePath>* changed_dirs) { | 413 std::set<FilePath>* changed_dirs) { |
| 415 GDataDirectory* dir = entry->AsGDataDirectory(); | 414 GDataDirectory* dir = entry->AsGDataDirectory(); |
| 416 if (!dir) | 415 if (!dir) |
| 417 return; | 416 return; |
| 418 | 417 |
| 419 for (GDataFileCollection::const_iterator it = dir->children().begin(); | 418 for (GDataDirectoryCollection::const_iterator it = |
| 420 it != dir->children().end(); ++it) { | 419 dir->child_directories().begin(); |
| 421 GDataDirectory* child_dir = it->second->AsGDataDirectory(); | 420 it != dir->child_directories().end(); ++it) { |
| 422 if (child_dir) { | 421 GDataDirectory* child_dir = it->second; |
| 423 changed_dirs->insert(child_dir->GetFilePath()); | 422 changed_dirs->insert(child_dir->GetFilePath()); |
| 424 GetChildDirectoryPaths(child_dir, changed_dirs); | 423 GetChildDirectoryPaths(child_dir, changed_dirs); |
| 425 } | |
| 426 } | 424 } |
| 427 } | 425 } |
| 428 | 426 |
| 429 | 427 |
| 430 // Helper function for removing |entry| from |directory|. If |entry| is a | 428 // Helper function for removing |entry| from |directory|. If |entry| is a |
| 431 // directory too, it will collect all its children file paths into | 429 // directory too, it will collect all its children file paths into |
| 432 // |changed_dirs| as well. | 430 // |changed_dirs| as well. |
| 433 void RemoveEntryFromDirectoryAndCollectChangedDirectories( | 431 void RemoveEntryFromDirectoryAndCollectChangedDirectories( |
| 434 GDataDirectory* directory, | 432 GDataDirectory* directory, |
| 435 GDataEntry* entry, | 433 GDataEntry* entry, |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 | 836 |
| 839 FilePath cache_base_path; | 837 FilePath cache_base_path; |
| 840 chrome::GetUserCacheDirectory(profile_->GetPath(), &cache_base_path); | 838 chrome::GetUserCacheDirectory(profile_->GetPath(), &cache_base_path); |
| 841 gdata_cache_path_ = cache_base_path.Append(chrome::kGDataCacheDirname); | 839 gdata_cache_path_ = cache_base_path.Append(chrome::kGDataCacheDirname); |
| 842 gdata_cache_path_ = gdata_cache_path_.Append(kGDataCacheVersionDir); | 840 gdata_cache_path_ = gdata_cache_path_.Append(kGDataCacheVersionDir); |
| 843 SetCachePaths(gdata_cache_path_); | 841 SetCachePaths(gdata_cache_path_); |
| 844 | 842 |
| 845 documents_service_->Initialize(profile_); | 843 documents_service_->Initialize(profile_); |
| 846 | 844 |
| 847 root_.reset(new GDataRootDirectory); | 845 root_.reset(new GDataRootDirectory); |
| 848 root_->set_file_name(kGDataRootDirectory); | |
| 849 | 846 |
| 850 PrefService* pref_service = profile_->GetPrefs(); | 847 PrefService* pref_service = profile_->GetPrefs(); |
| 851 hide_hosted_docs_ = pref_service->GetBoolean(prefs::kDisableGDataHostedFiles); | 848 hide_hosted_docs_ = pref_service->GetBoolean(prefs::kDisableGDataHostedFiles); |
| 852 | 849 |
| 853 InitializePreferenceObserver(); | 850 InitializePreferenceObserver(); |
| 854 } | 851 } |
| 855 | 852 |
| 856 bool GDataFileSystem::SetCacheRootPathForTesting(const FilePath& root_path) { | 853 bool GDataFileSystem::SetCacheRootPathForTesting(const FilePath& root_path) { |
| 857 if (cache_initialization_started_) | 854 if (cache_initialization_started_) |
| 858 return false; | 855 return false; |
| (...skipping 3408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4267 pref_registrar_->Init(profile_->GetPrefs()); | 4264 pref_registrar_->Init(profile_->GetPrefs()); |
| 4268 pref_registrar_->Add(prefs::kDisableGDataHostedFiles, this); | 4265 pref_registrar_->Add(prefs::kDisableGDataHostedFiles, this); |
| 4269 } | 4266 } |
| 4270 | 4267 |
| 4271 void SetFreeDiskSpaceGetterForTesting(FreeDiskSpaceGetterInterface* getter) { | 4268 void SetFreeDiskSpaceGetterForTesting(FreeDiskSpaceGetterInterface* getter) { |
| 4272 delete global_free_disk_getter_for_testing; // Safe to delete NULL; | 4269 delete global_free_disk_getter_for_testing; // Safe to delete NULL; |
| 4273 global_free_disk_getter_for_testing = getter; | 4270 global_free_disk_getter_for_testing = getter; |
| 4274 } | 4271 } |
| 4275 | 4272 |
| 4276 } // namespace gdata | 4273 } // namespace gdata |
| OLD | NEW |