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

Side by Side Diff: extensions/browser/api/system_storage/system_storage_api.cc

Issue 389633002: Move system.* family of APIs to extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Better comments Created 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/api/system_storage/system_storage_api.h" 5 #include "extensions/browser/api/system_storage/system_storage_api.h"
6 6
7 using storage_monitor::StorageMonitor; 7 using storage_monitor::StorageMonitor;
8 8
9 namespace extensions { 9 namespace extensions {
10 10
11 using api::system_storage::StorageUnitInfo; 11 using core_api::system_storage::StorageUnitInfo;
12 namespace EjectDevice = api::system_storage::EjectDevice; 12 namespace EjectDevice = core_api::system_storage::EjectDevice;
13 namespace GetAvailableCapacity = api::system_storage::GetAvailableCapacity; 13 namespace GetAvailableCapacity = core_api::system_storage::GetAvailableCapacity;
14 14
15 SystemStorageGetInfoFunction::SystemStorageGetInfoFunction() { 15 SystemStorageGetInfoFunction::SystemStorageGetInfoFunction() {
16 } 16 }
17 17
18 SystemStorageGetInfoFunction::~SystemStorageGetInfoFunction() { 18 SystemStorageGetInfoFunction::~SystemStorageGetInfoFunction() {
19 } 19 }
20 20
21 bool SystemStorageGetInfoFunction::RunAsync() { 21 bool SystemStorageGetInfoFunction::RunAsync() {
22 StorageInfoProvider::Get()->StartQueryInfo( 22 StorageInfoProvider::Get()->StartQueryInfo(
23 base::Bind(&SystemStorageGetInfoFunction::OnGetStorageInfoCompleted, 23 base::Bind(&SystemStorageGetInfoFunction::OnGetStorageInfoCompleted,
24 this)); 24 this));
25 return true; 25 return true;
26 } 26 }
27 27
28 void SystemStorageGetInfoFunction::OnGetStorageInfoCompleted(bool success) { 28 void SystemStorageGetInfoFunction::OnGetStorageInfoCompleted(bool success) {
29 if (success) { 29 if (success) {
30 results_ = api::system_storage::GetInfo::Results::Create( 30 results_ = core_api::system_storage::GetInfo::Results::Create(
31 StorageInfoProvider::Get()->storage_unit_info_list()); 31 StorageInfoProvider::Get()->storage_unit_info_list());
32 } else { 32 } else {
33 SetError("Error occurred when querying storage information."); 33 SetError("Error occurred when querying storage information.");
34 } 34 }
35 35
36 SendResponse(success); 36 SendResponse(success);
37 } 37 }
38 38
39 SystemStorageEjectDeviceFunction::~SystemStorageEjectDeviceFunction() { 39 SystemStorageEjectDeviceFunction::~SystemStorageEjectDeviceFunction() {
40 } 40 }
(...skipping 25 matching lines...) Expand all
66 } 66 }
67 67
68 monitor->EjectDevice( 68 monitor->EjectDevice(
69 device_id_str, 69 device_id_str,
70 base::Bind(&SystemStorageEjectDeviceFunction::HandleResponse, 70 base::Bind(&SystemStorageEjectDeviceFunction::HandleResponse,
71 this)); 71 this));
72 } 72 }
73 73
74 void SystemStorageEjectDeviceFunction::HandleResponse( 74 void SystemStorageEjectDeviceFunction::HandleResponse(
75 StorageMonitor::EjectStatus status) { 75 StorageMonitor::EjectStatus status) {
76 api::system_storage:: EjectDeviceResultCode result = 76 core_api::system_storage:: EjectDeviceResultCode result =
77 api::system_storage::EJECT_DEVICE_RESULT_CODE_FAILURE; 77 core_api::system_storage::EJECT_DEVICE_RESULT_CODE_FAILURE;
78 switch (status) { 78 switch (status) {
79 case StorageMonitor::EJECT_OK: 79 case StorageMonitor::EJECT_OK:
80 result = api::system_storage::EJECT_DEVICE_RESULT_CODE_SUCCESS; 80 result = core_api::system_storage::EJECT_DEVICE_RESULT_CODE_SUCCESS;
81 break; 81 break;
82 case StorageMonitor::EJECT_IN_USE: 82 case StorageMonitor::EJECT_IN_USE:
83 result = api::system_storage::EJECT_DEVICE_RESULT_CODE_IN_USE; 83 result = core_api::system_storage::EJECT_DEVICE_RESULT_CODE_IN_USE;
84 break; 84 break;
85 case StorageMonitor::EJECT_NO_SUCH_DEVICE: 85 case StorageMonitor::EJECT_NO_SUCH_DEVICE:
86 result = api::system_storage:: 86 result = core_api::system_storage::
87 EJECT_DEVICE_RESULT_CODE_NO_SUCH_DEVICE; 87 EJECT_DEVICE_RESULT_CODE_NO_SUCH_DEVICE;
88 break; 88 break;
89 case StorageMonitor::EJECT_FAILURE: 89 case StorageMonitor::EJECT_FAILURE:
90 result = api::system_storage::EJECT_DEVICE_RESULT_CODE_FAILURE; 90 result = core_api::system_storage::EJECT_DEVICE_RESULT_CODE_FAILURE;
91 } 91 }
92 92
93 SetResult(new base::StringValue( 93 SetResult(new base::StringValue(
94 api::system_storage::ToString(result))); 94 core_api::system_storage::ToString(result)));
95 SendResponse(true); 95 SendResponse(true);
96 } 96 }
97 97
98 SystemStorageGetAvailableCapacityFunction:: 98 SystemStorageGetAvailableCapacityFunction::
99 SystemStorageGetAvailableCapacityFunction() { 99 SystemStorageGetAvailableCapacityFunction() {
100 } 100 }
101 101
102 SystemStorageGetAvailableCapacityFunction:: 102 SystemStorageGetAvailableCapacityFunction::
103 ~SystemStorageGetAvailableCapacityFunction() { 103 ~SystemStorageGetAvailableCapacityFunction() {
104 } 104 }
(...skipping 22 matching lines...) Expand all
127 StorageInfoProvider::Get(), transient_id), 127 StorageInfoProvider::Get(), transient_id),
128 base::Bind( 128 base::Bind(
129 &SystemStorageGetAvailableCapacityFunction::OnQueryCompleted, 129 &SystemStorageGetAvailableCapacityFunction::OnQueryCompleted,
130 this, transient_id)); 130 this, transient_id));
131 } 131 }
132 132
133 void SystemStorageGetAvailableCapacityFunction::OnQueryCompleted( 133 void SystemStorageGetAvailableCapacityFunction::OnQueryCompleted(
134 const std::string& transient_id, double available_capacity) { 134 const std::string& transient_id, double available_capacity) {
135 bool success = available_capacity >= 0; 135 bool success = available_capacity >= 0;
136 if (success) { 136 if (success) {
137 api::system_storage::StorageAvailableCapacityInfo result; 137 core_api::system_storage::StorageAvailableCapacityInfo result;
138 result.id = transient_id; 138 result.id = transient_id;
139 result.available_capacity = available_capacity; 139 result.available_capacity = available_capacity;
140 SetResult(result.ToValue().release()); 140 SetResult(result.ToValue().release());
141 } else { 141 } else {
142 SetError("Error occurred when querying available capacity."); 142 SetError("Error occurred when querying available capacity.");
143 } 143 }
144 SendResponse(success); 144 SendResponse(success);
145 } 145 }
146 146
147 } // namespace extensions 147 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698