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

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

Issue 1226353004: Generate all extension schema namespaces as "api" and instead vary the generated bundle names. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 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 "extensions/browser/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 core_api::system_storage::StorageUnitInfo; 11 using api::system_storage::StorageUnitInfo;
12 namespace EjectDevice = core_api::system_storage::EjectDevice; 12 namespace EjectDevice = api::system_storage::EjectDevice;
13 namespace GetAvailableCapacity = core_api::system_storage::GetAvailableCapacity; 13 namespace GetAvailableCapacity = 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(base::Bind( 22 StorageInfoProvider::Get()->StartQueryInfo(base::Bind(
23 &SystemStorageGetInfoFunction::OnGetStorageInfoCompleted, this)); 23 &SystemStorageGetInfoFunction::OnGetStorageInfoCompleted, this));
24 return true; 24 return true;
25 } 25 }
26 26
27 void SystemStorageGetInfoFunction::OnGetStorageInfoCompleted(bool success) { 27 void SystemStorageGetInfoFunction::OnGetStorageInfoCompleted(bool success) {
28 if (success) { 28 if (success) {
29 results_ = core_api::system_storage::GetInfo::Results::Create( 29 results_ = api::system_storage::GetInfo::Results::Create(
30 StorageInfoProvider::Get()->storage_unit_info_list()); 30 StorageInfoProvider::Get()->storage_unit_info_list());
31 } else { 31 } else {
32 SetError("Error occurred when querying storage information."); 32 SetError("Error occurred when querying storage information.");
33 } 33 }
34 34
35 SendResponse(success); 35 SendResponse(success);
36 } 36 }
37 37
38 SystemStorageEjectDeviceFunction::~SystemStorageEjectDeviceFunction() { 38 SystemStorageEjectDeviceFunction::~SystemStorageEjectDeviceFunction() {
39 } 39 }
(...skipping 24 matching lines...) Expand all
64 return; 64 return;
65 } 65 }
66 66
67 monitor->EjectDevice( 67 monitor->EjectDevice(
68 device_id_str, 68 device_id_str,
69 base::Bind(&SystemStorageEjectDeviceFunction::HandleResponse, this)); 69 base::Bind(&SystemStorageEjectDeviceFunction::HandleResponse, this));
70 } 70 }
71 71
72 void SystemStorageEjectDeviceFunction::HandleResponse( 72 void SystemStorageEjectDeviceFunction::HandleResponse(
73 StorageMonitor::EjectStatus status) { 73 StorageMonitor::EjectStatus status) {
74 core_api::system_storage::EjectDeviceResultCode result = 74 api::system_storage::EjectDeviceResultCode result =
75 core_api::system_storage::EJECT_DEVICE_RESULT_CODE_FAILURE; 75 api::system_storage::EJECT_DEVICE_RESULT_CODE_FAILURE;
76 switch (status) { 76 switch (status) {
77 case StorageMonitor::EJECT_OK: 77 case StorageMonitor::EJECT_OK:
78 result = core_api::system_storage::EJECT_DEVICE_RESULT_CODE_SUCCESS; 78 result = api::system_storage::EJECT_DEVICE_RESULT_CODE_SUCCESS;
79 break; 79 break;
80 case StorageMonitor::EJECT_IN_USE: 80 case StorageMonitor::EJECT_IN_USE:
81 result = core_api::system_storage::EJECT_DEVICE_RESULT_CODE_IN_USE; 81 result = api::system_storage::EJECT_DEVICE_RESULT_CODE_IN_USE;
82 break; 82 break;
83 case StorageMonitor::EJECT_NO_SUCH_DEVICE: 83 case StorageMonitor::EJECT_NO_SUCH_DEVICE:
84 result = 84 result = api::system_storage::EJECT_DEVICE_RESULT_CODE_NO_SUCH_DEVICE;
85 core_api::system_storage::EJECT_DEVICE_RESULT_CODE_NO_SUCH_DEVICE;
86 break; 85 break;
87 case StorageMonitor::EJECT_FAILURE: 86 case StorageMonitor::EJECT_FAILURE:
88 result = core_api::system_storage::EJECT_DEVICE_RESULT_CODE_FAILURE; 87 result = api::system_storage::EJECT_DEVICE_RESULT_CODE_FAILURE;
89 } 88 }
90 89
91 SetResult(new base::StringValue(core_api::system_storage::ToString(result))); 90 SetResult(new base::StringValue(api::system_storage::ToString(result)));
92 SendResponse(true); 91 SendResponse(true);
93 } 92 }
94 93
95 SystemStorageGetAvailableCapacityFunction:: 94 SystemStorageGetAvailableCapacityFunction::
96 SystemStorageGetAvailableCapacityFunction() { 95 SystemStorageGetAvailableCapacityFunction() {
97 } 96 }
98 97
99 SystemStorageGetAvailableCapacityFunction:: 98 SystemStorageGetAvailableCapacityFunction::
100 ~SystemStorageGetAvailableCapacityFunction() { 99 ~SystemStorageGetAvailableCapacityFunction() {
101 } 100 }
(...skipping 24 matching lines...) Expand all
126 base::Bind(&SystemStorageGetAvailableCapacityFunction::OnQueryCompleted, 125 base::Bind(&SystemStorageGetAvailableCapacityFunction::OnQueryCompleted,
127 this, 126 this,
128 transient_id)); 127 transient_id));
129 } 128 }
130 129
131 void SystemStorageGetAvailableCapacityFunction::OnQueryCompleted( 130 void SystemStorageGetAvailableCapacityFunction::OnQueryCompleted(
132 const std::string& transient_id, 131 const std::string& transient_id,
133 double available_capacity) { 132 double available_capacity) {
134 bool success = available_capacity >= 0; 133 bool success = available_capacity >= 0;
135 if (success) { 134 if (success) {
136 core_api::system_storage::StorageAvailableCapacityInfo result; 135 api::system_storage::StorageAvailableCapacityInfo result;
137 result.id = transient_id; 136 result.id = transient_id;
138 result.available_capacity = available_capacity; 137 result.available_capacity = available_capacity;
139 SetResult(result.ToValue().release()); 138 SetResult(result.ToValue().release());
140 } else { 139 } else {
141 SetError("Error occurred when querying available capacity."); 140 SetError("Error occurred when querying available capacity.");
142 } 141 }
143 SendResponse(success); 142 SendResponse(success);
144 } 143 }
145 144
146 } // namespace extensions 145 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/system_storage/storage_info_provider.cc ('k') | extensions/browser/api/test/test_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698