| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/files/file_util.h" | 16 #include "base/files/file_util.h" |
| 17 #include "base/i18n/icu_string_conversions.h" | 17 #include "base/i18n/icu_string_conversions.h" |
| 18 #include "base/json/json_file_value_serializer.h" | 18 #include "base/json/json_file_value_serializer.h" |
| 19 #include "base/logging.h" | 19 #include "base/logging.h" |
| 20 #include "base/macros.h" | 20 #include "base/macros.h" |
| 21 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
| 22 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
| 23 #include "base/task_scheduler/post_task.h" |
| 23 #include "base/threading/sequenced_worker_pool.h" | 24 #include "base/threading/sequenced_worker_pool.h" |
| 24 #include "base/threading/thread_task_runner_handle.h" | 25 #include "base/threading/thread_task_runner_handle.h" |
| 25 #include "chrome/browser/browser_process.h" | 26 #include "chrome/browser/browser_process.h" |
| 26 #include "chrome/browser/chromeos/drive/drive_integration_service.h" | 27 #include "chrome/browser/chromeos/drive/drive_integration_service.h" |
| 27 #include "chrome/browser/chromeos/drive/write_on_cache_file.h" | 28 #include "chrome/browser/chromeos/drive/write_on_cache_file.h" |
| 28 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 29 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 29 #include "chrome/browser/chromeos/profiles/profile_util.h" | 30 #include "chrome/browser/chromeos/profiles/profile_util.h" |
| 30 #include "chrome/browser/profiles/profile.h" | 31 #include "chrome/browser/profiles/profile.h" |
| 31 #include "chrome/browser/profiles/profile_manager.h" | 32 #include "chrome/browser/profiles/profile_manager.h" |
| 32 #include "chrome/common/chrome_constants.h" | 33 #include "chrome/common/chrome_constants.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 } | 187 } |
| 187 | 188 |
| 188 void PrepareWritableFileAndRun(Profile* profile, | 189 void PrepareWritableFileAndRun(Profile* profile, |
| 189 const base::FilePath& path, | 190 const base::FilePath& path, |
| 190 const PrepareWritableFileCallback& callback) { | 191 const PrepareWritableFileCallback& callback) { |
| 191 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 192 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 192 DCHECK(!callback.is_null()); | 193 DCHECK(!callback.is_null()); |
| 193 | 194 |
| 194 FileSystemInterface* file_system = GetFileSystemByProfile(profile); | 195 FileSystemInterface* file_system = GetFileSystemByProfile(profile); |
| 195 if (!file_system || !IsUnderDriveMountPoint(path)) { | 196 if (!file_system || !IsUnderDriveMountPoint(path)) { |
| 196 content::BrowserThread::GetBlockingPool()->PostTask( | 197 base::PostTaskWithTraits( |
| 197 FROM_HERE, | 198 FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_BLOCKING}, |
| 198 base::BindOnce(callback, FILE_ERROR_FAILED, base::FilePath())); | 199 base::BindOnce(callback, FILE_ERROR_FAILED, base::FilePath())); |
| 199 return; | 200 return; |
| 200 } | 201 } |
| 201 | 202 |
| 202 WriteOnCacheFile(file_system, ExtractDrivePath(path), | 203 WriteOnCacheFile(file_system, ExtractDrivePath(path), |
| 203 std::string(), // mime_type | 204 std::string(), // mime_type |
| 204 callback); | 205 callback); |
| 205 } | 206 } |
| 206 | 207 |
| 207 void EnsureDirectoryExists(Profile* profile, | 208 void EnsureDirectoryExists(Profile* profile, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 const bool disable_sync_over_celluar = | 253 const bool disable_sync_over_celluar = |
| 253 profile->GetPrefs()->GetBoolean(prefs::kDisableDriveOverCellular); | 254 profile->GetPrefs()->GetBoolean(prefs::kDisableDriveOverCellular); |
| 254 | 255 |
| 255 if (is_connection_cellular && disable_sync_over_celluar) | 256 if (is_connection_cellular && disable_sync_over_celluar) |
| 256 return DRIVE_CONNECTED_METERED; | 257 return DRIVE_CONNECTED_METERED; |
| 257 return DRIVE_CONNECTED; | 258 return DRIVE_CONNECTED; |
| 258 } | 259 } |
| 259 | 260 |
| 260 } // namespace util | 261 } // namespace util |
| 261 } // namespace drive | 262 } // namespace drive |
| OLD | NEW |