| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/extensions/updater/chromeos_extension_cache_delegate.h" | 5 #include "chrome/browser/extensions/updater/chromeos_extension_cache_delegate.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/path_service.h" |
| 9 #include "chrome/browser/chromeos/settings/cros_settings.h" | 10 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 11 #include "chromeos/chromeos_paths.h" |
| 10 #include "chromeos/settings/cros_settings_names.h" | 12 #include "chromeos/settings/cros_settings_names.h" |
| 11 | 13 |
| 12 namespace extensions { | 14 namespace extensions { |
| 13 namespace { | |
| 14 | 15 |
| 15 const char kLocalCacheDir[] = "/var/cache/external_cache"; | 16 ChromeOSExtensionCacheDelegate::ChromeOSExtensionCacheDelegate() { |
| 16 | 17 CHECK(PathService::Get(chromeos::DIR_DEVICE_EXTENSION_LOCAL_CACHE, |
| 17 } // namespace | 18 &cache_dir_)); |
| 18 | |
| 19 ChromeOSExtensionCacheDelegate::ChromeOSExtensionCacheDelegate() | |
| 20 : cache_dir_(kLocalCacheDir) { | |
| 21 } | 19 } |
| 22 | 20 |
| 23 ChromeOSExtensionCacheDelegate::ChromeOSExtensionCacheDelegate( | 21 ChromeOSExtensionCacheDelegate::ChromeOSExtensionCacheDelegate( |
| 24 const base::FilePath& cache_dir) | 22 const base::FilePath& cache_dir) |
| 25 : cache_dir_(cache_dir) { | 23 : cache_dir_(cache_dir) { |
| 26 } | 24 } |
| 27 | 25 |
| 28 const base::FilePath& ChromeOSExtensionCacheDelegate::GetCacheDir() const { | 26 const base::FilePath& ChromeOSExtensionCacheDelegate::GetCacheDir() const { |
| 29 return cache_dir_; | 27 return cache_dir_; |
| 30 } | 28 } |
| 31 | 29 |
| 32 size_t ChromeOSExtensionCacheDelegate::GetMaximumCacheSize() const { | 30 size_t ChromeOSExtensionCacheDelegate::GetMaximumCacheSize() const { |
| 33 size_t max_size = ExtensionCacheDelegate::GetMaximumCacheSize(); | 31 size_t max_size = ExtensionCacheDelegate::GetMaximumCacheSize(); |
| 34 int policy_size = 0; | 32 int policy_size = 0; |
| 35 if (chromeos::CrosSettings::Get()->GetInteger(chromeos::kExtensionCacheSize, | 33 if (chromeos::CrosSettings::Get()->GetInteger(chromeos::kExtensionCacheSize, |
| 36 &policy_size) && | 34 &policy_size) && |
| 37 policy_size >= static_cast<int>(GetMinimumCacheSize())) { | 35 policy_size >= static_cast<int>(GetMinimumCacheSize())) { |
| 38 max_size = policy_size; | 36 max_size = policy_size; |
| 39 } | 37 } |
| 40 return max_size; | 38 return max_size; |
| 41 } | 39 } |
| 42 | 40 |
| 43 } // namespace extensions | 41 } // namespace extensions |
| OLD | NEW |