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

Side by Side Diff: components/arc/storage_manager/arc_storage_manager.cc

Issue 2133503002: arc: Revamp the ArcBridgeService interface (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: More rebasing Created 4 years, 5 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
OLDNEW
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"
11 #include "components/arc/arc_bridge_service.h" 11 #include "components/arc/arc_bridge_service.h"
12 12
13 namespace arc { 13 namespace arc {
14 14
15 namespace { 15 namespace {
16 16
17 const int kMinInstanceVersion = 1; // See storage_manager.mojom. 17 const int kMinInstanceVersion = 1; // See storage_manager.mojom.
18 18
19 // This class is owned by ArcServiceManager so that it is safe to use this raw 19 // This class is owned by ArcServiceManager so that it is safe to use this raw
20 // pointer as the singleton reference. 20 // pointer as the singleton reference.
21 ArcStorageManager* g_arc_storage_manager = nullptr; 21 ArcStorageManager* g_arc_storage_manager = nullptr;
22 22
23 } // namespace 23 } // namespace
24 24
25 ArcStorageManager::ArcStorageManager(ArcBridgeService *bridge_service) 25 ArcStorageManager::ArcStorageManager(ArcBridgeService* bridge_service)
26 : ArcService(bridge_service) { 26 : ArcService(bridge_service) {
27 DCHECK(!g_arc_storage_manager); 27 DCHECK(!g_arc_storage_manager);
28 g_arc_storage_manager = this; 28 g_arc_storage_manager = this;
29 } 29 }
30 30
31 ArcStorageManager::~ArcStorageManager() { 31 ArcStorageManager::~ArcStorageManager() {
32 DCHECK_EQ(this, g_arc_storage_manager); 32 DCHECK_EQ(this, g_arc_storage_manager);
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 void ArcStorageManager::OnStorageManagerInstanceReady() {
43 VLOG(1) << "ArcStorageManagerInstance is ready";
44 }
45
46 bool ArcStorageManager::OpenPrivateVolumeSettings() { 42 bool ArcStorageManager::OpenPrivateVolumeSettings() {
47 auto storage_manager_instance = GetStorageManagerInstance(); 43 auto storage_manager_instance = GetStorageManagerInstance();
48 if (!storage_manager_instance) { 44 if (!storage_manager_instance) {
49 return false; 45 return false;
50 } 46 }
51 storage_manager_instance->OpenPrivateVolumeSettings(); 47 storage_manager_instance->OpenPrivateVolumeSettings();
52 return true; 48 return true;
53 } 49 }
54 50
55 bool ArcStorageManager::GetApplicationsSize( 51 bool ArcStorageManager::GetApplicationsSize(
(...skipping 11 matching lines...) Expand all
67 auto storage_manager_instance = GetStorageManagerInstance(); 63 auto storage_manager_instance = GetStorageManagerInstance();
68 if (!storage_manager_instance) { 64 if (!storage_manager_instance) {
69 return false; 65 return false;
70 } 66 }
71 storage_manager_instance->DeleteApplicationsCache(callback); 67 storage_manager_instance->DeleteApplicationsCache(callback);
72 return true; 68 return true;
73 } 69 }
74 70
75 mojom::StorageManagerInstance* ArcStorageManager::GetStorageManagerInstance() { 71 mojom::StorageManagerInstance* ArcStorageManager::GetStorageManagerInstance() {
76 auto bridge_service = arc_bridge_service(); 72 auto bridge_service = arc_bridge_service();
77 auto storage_manager_instance = bridge_service->storage_manager_instance(); 73 auto storage_manager_instance = bridge_service->storage_manager()->instance();
78 if (!storage_manager_instance) { 74 if (!storage_manager_instance) {
79 DLOG(WARNING) << "ARC storage manager instance is not ready."; 75 DLOG(WARNING) << "ARC storage manager instance is not ready.";
80 return nullptr; 76 return nullptr;
81 } 77 }
82 auto storage_manager_version = bridge_service->storage_manager_version(); 78 auto storage_manager_version = bridge_service->storage_manager()->version();
83 if (storage_manager_version < kMinInstanceVersion) { 79 if (storage_manager_version < kMinInstanceVersion) {
84 DLOG(ERROR) << "ARC storage manager instance (version " 80 DLOG(ERROR) << "ARC storage manager instance (version "
85 << storage_manager_version << ") is too old."; 81 << storage_manager_version << ") is too old.";
86 return nullptr; 82 return nullptr;
87 } 83 }
88 return storage_manager_instance; 84 return storage_manager_instance;
89 } 85 }
90 86
91 } // namespace arc 87 } // namespace arc
OLDNEW
« no previous file with comments | « components/arc/storage_manager/arc_storage_manager.h ('k') | components/arc/test/fake_policy_instance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698