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

Side by Side Diff: chrome/browser/chromeos/drive/drive_integration_service.cc

Issue 445473002: Remove ResourceIdCanonicalizer from DriveServiceInterface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/file_system.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/chromeos/drive/drive_integration_service.h" 5 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/prefs/pref_change_registrar.h" 9 #include "base/prefs/pref_change_registrar.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 os_cpu_info.c_str()); 96 os_cpu_info.c_str());
97 } 97 }
98 98
99 // Initializes FileCache and ResourceMetadata. 99 // Initializes FileCache and ResourceMetadata.
100 // Must be run on the same task runner used by |cache| and |resource_metadata|. 100 // Must be run on the same task runner used by |cache| and |resource_metadata|.
101 FileError InitializeMetadata( 101 FileError InitializeMetadata(
102 const base::FilePath& cache_root_directory, 102 const base::FilePath& cache_root_directory,
103 internal::ResourceMetadataStorage* metadata_storage, 103 internal::ResourceMetadataStorage* metadata_storage,
104 internal::FileCache* cache, 104 internal::FileCache* cache,
105 internal::ResourceMetadata* resource_metadata, 105 internal::ResourceMetadata* resource_metadata,
106 const ResourceIdCanonicalizer& id_canonicalizer,
107 const base::FilePath& downloads_directory) { 106 const base::FilePath& downloads_directory) {
108 // Files in temporary directory need not persist across sessions. Clean up 107 // Files in temporary directory need not persist across sessions. Clean up
109 // the directory content while initialization. 108 // the directory content while initialization.
110 base::DeleteFile(cache_root_directory.Append(kTemporaryFileDirectory), 109 base::DeleteFile(cache_root_directory.Append(kTemporaryFileDirectory),
111 true); // recursive 110 true); // recursive
112 if (!base::CreateDirectory(cache_root_directory.Append( 111 if (!base::CreateDirectory(cache_root_directory.Append(
113 kMetadataDirectory)) || 112 kMetadataDirectory)) ||
114 !base::CreateDirectory(cache_root_directory.Append( 113 !base::CreateDirectory(cache_root_directory.Append(
115 kCacheFileDirectory)) || 114 kCacheFileDirectory)) ||
116 !base::CreateDirectory(cache_root_directory.Append( 115 !base::CreateDirectory(cache_root_directory.Append(
117 kTemporaryFileDirectory))) { 116 kTemporaryFileDirectory))) {
118 LOG(WARNING) << "Failed to create directories."; 117 LOG(WARNING) << "Failed to create directories.";
119 return FILE_ERROR_FAILED; 118 return FILE_ERROR_FAILED;
120 } 119 }
121 120
122 // Change permissions of cache file directory to u+rwx,og+x (711) in order to 121 // Change permissions of cache file directory to u+rwx,og+x (711) in order to
123 // allow archive files in that directory to be mounted by cros-disks. 122 // allow archive files in that directory to be mounted by cros-disks.
124 base::SetPosixFilePermissions( 123 base::SetPosixFilePermissions(
125 cache_root_directory.Append(kCacheFileDirectory), 124 cache_root_directory.Append(kCacheFileDirectory),
126 base::FILE_PERMISSION_USER_MASK | 125 base::FILE_PERMISSION_USER_MASK |
127 base::FILE_PERMISSION_EXECUTE_BY_GROUP | 126 base::FILE_PERMISSION_EXECUTE_BY_GROUP |
128 base::FILE_PERMISSION_EXECUTE_BY_OTHERS); 127 base::FILE_PERMISSION_EXECUTE_BY_OTHERS);
129 128
130 internal::ResourceMetadataStorage::UpgradeOldDB( 129 internal::ResourceMetadataStorage::UpgradeOldDB(
131 metadata_storage->directory_path(), id_canonicalizer); 130 metadata_storage->directory_path());
132 131
133 if (!metadata_storage->Initialize()) { 132 if (!metadata_storage->Initialize()) {
134 LOG(WARNING) << "Failed to initialize the metadata storage."; 133 LOG(WARNING) << "Failed to initialize the metadata storage.";
135 return FILE_ERROR_FAILED; 134 return FILE_ERROR_FAILED;
136 } 135 }
137 136
138 if (!cache->Initialize()) { 137 if (!cache->Initialize()) {
139 LOG(WARNING) << "Failed to initialize the cache."; 138 LOG(WARNING) << "Failed to initialize the cache.";
140 return FILE_ERROR_FAILED; 139 return FILE_ERROR_FAILED;
141 } 140 }
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 state_ = INITIALIZING; 477 state_ = INITIALIZING;
479 478
480 base::PostTaskAndReplyWithResult( 479 base::PostTaskAndReplyWithResult(
481 blocking_task_runner_.get(), 480 blocking_task_runner_.get(),
482 FROM_HERE, 481 FROM_HERE,
483 base::Bind(&InitializeMetadata, 482 base::Bind(&InitializeMetadata,
484 cache_root_directory_, 483 cache_root_directory_,
485 metadata_storage_.get(), 484 metadata_storage_.get(),
486 cache_.get(), 485 cache_.get(),
487 resource_metadata_.get(), 486 resource_metadata_.get(),
488 drive_service_->GetResourceIdCanonicalizer(),
489 file_manager::util::GetDownloadsFolderForProfile(profile_)), 487 file_manager::util::GetDownloadsFolderForProfile(profile_)),
490 base::Bind(&DriveIntegrationService::InitializeAfterMetadataInitialized, 488 base::Bind(&DriveIntegrationService::InitializeAfterMetadataInitialized,
491 weak_ptr_factory_.GetWeakPtr())); 489 weak_ptr_factory_.GetWeakPtr()));
492 } 490 }
493 491
494 void DriveIntegrationService::InitializeAfterMetadataInitialized( 492 void DriveIntegrationService::InitializeAfterMetadataInitialized(
495 FileError error) { 493 FileError error) {
496 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 494 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
497 DCHECK_EQ(INITIALIZING, state_); 495 DCHECK_EQ(INITIALIZING, state_);
498 496
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 profile, preference_watcher, 646 profile, preference_watcher,
649 NULL, std::string(), base::FilePath(), NULL); 647 NULL, std::string(), base::FilePath(), NULL);
650 } else { 648 } else {
651 service = factory_for_test_->Run(profile); 649 service = factory_for_test_->Run(profile);
652 } 650 }
653 651
654 return service; 652 return service;
655 } 653 }
656 654
657 } // namespace drive 655 } // namespace drive
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/file_system.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698