OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/arc/storage_manager/arc_storage_manager.h" | 5 #include "components/arc/storage_manager/arc_storage_manager.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 g_arc_storage_manager = nullptr; | 33 g_arc_storage_manager = nullptr; |
34 } | 34 } |
35 | 35 |
36 // static | 36 // static |
37 ArcStorageManager* ArcStorageManager::Get() { | 37 ArcStorageManager* ArcStorageManager::Get() { |
38 DCHECK(g_arc_storage_manager); | 38 DCHECK(g_arc_storage_manager); |
39 return g_arc_storage_manager; | 39 return g_arc_storage_manager; |
40 } | 40 } |
41 | 41 |
42 bool ArcStorageManager::OpenPrivateVolumeSettings() { | 42 bool ArcStorageManager::OpenPrivateVolumeSettings() { |
43 auto* storage_manager_instance = GetStorageManagerInstance(); | 43 auto* storage_manager_instance = |
44 if (!storage_manager_instance) { | 44 arc_bridge_service()->storage_manager()->GetInstanceForMethod( |
| 45 "OpenPrivateVolumeSettings", kMinInstanceVersion); |
| 46 if (!storage_manager_instance) |
45 return false; | 47 return false; |
46 } | |
47 storage_manager_instance->OpenPrivateVolumeSettings(); | 48 storage_manager_instance->OpenPrivateVolumeSettings(); |
48 return true; | 49 return true; |
49 } | 50 } |
50 | 51 |
51 bool ArcStorageManager::GetApplicationsSize( | 52 bool ArcStorageManager::GetApplicationsSize( |
52 const GetApplicationsSizeCallback& callback) { | 53 const GetApplicationsSizeCallback& callback) { |
53 auto* storage_manager_instance = GetStorageManagerInstance(); | 54 auto* storage_manager_instance = |
54 if (!storage_manager_instance) { | 55 arc_bridge_service()->storage_manager()->GetInstanceForMethod( |
| 56 "GetApplicationsSize", kMinInstanceVersion); |
| 57 if (!storage_manager_instance) |
55 return false; | 58 return false; |
56 } | |
57 storage_manager_instance->GetApplicationsSize(callback); | 59 storage_manager_instance->GetApplicationsSize(callback); |
58 return true; | 60 return true; |
59 } | 61 } |
60 | 62 |
61 bool ArcStorageManager::DeleteApplicationsCache( | 63 bool ArcStorageManager::DeleteApplicationsCache( |
62 const base::Callback<void()>& callback) { | 64 const base::Callback<void()>& callback) { |
63 auto* storage_manager_instance = GetStorageManagerInstance(); | 65 auto* storage_manager_instance = |
64 if (!storage_manager_instance) { | 66 arc_bridge_service()->storage_manager()->GetInstanceForMethod( |
| 67 "DeleteApplicationsCache", kMinInstanceVersion); |
| 68 if (!storage_manager_instance) |
65 return false; | 69 return false; |
66 } | |
67 storage_manager_instance->DeleteApplicationsCache(callback); | 70 storage_manager_instance->DeleteApplicationsCache(callback); |
68 return true; | 71 return true; |
69 } | 72 } |
70 | 73 |
71 mojom::StorageManagerInstance* ArcStorageManager::GetStorageManagerInstance() { | |
72 auto* bridge_service = arc_bridge_service(); | |
73 auto* storage_manager_instance = | |
74 bridge_service->storage_manager()->instance(); | |
75 if (!storage_manager_instance) { | |
76 DLOG(WARNING) << "ARC storage manager instance is not ready."; | |
77 return nullptr; | |
78 } | |
79 auto storage_manager_version = bridge_service->storage_manager()->version(); | |
80 if (storage_manager_version < kMinInstanceVersion) { | |
81 DLOG(ERROR) << "ARC storage manager instance (version " | |
82 << storage_manager_version << ") is too old."; | |
83 return nullptr; | |
84 } | |
85 return storage_manager_instance; | |
86 } | |
87 | |
88 } // namespace arc | 74 } // namespace arc |
OLD | NEW |