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

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

Issue 18578008: [SystemInfo API] Move Storage API out of experimental namespace and rename to the "system" namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/extensions/api/system_info_storage/system_info_storage_ api.h" 4 #include "chrome/browser/extensions/api/system_storage/system_storage_api.h"
5 5
6 namespace extensions { 6 namespace extensions {
7 7
8 using api::experimental_system_info_storage::StorageUnitInfo; 8 using api::system_storage::StorageUnitInfo;
9 namespace EjectDevice = api::experimental_system_info_storage::EjectDevice; 9 namespace EjectDevice = api::system_storage::EjectDevice;
10 10
11 SystemInfoStorageGetFunction::SystemInfoStorageGetFunction() { 11 SystemStorageGetInfoFunction::SystemStorageGetInfoFunction() {
12 } 12 }
13 13
14 SystemInfoStorageGetFunction::~SystemInfoStorageGetFunction() { 14 SystemStorageGetInfoFunction::~SystemStorageGetInfoFunction() {
15 } 15 }
16 16
17 bool SystemInfoStorageGetFunction::RunImpl() { 17 bool SystemStorageGetInfoFunction::RunImpl() {
18 StorageInfoProvider::Get()->StartQueryInfo( 18 StorageInfoProvider::Get()->StartQueryInfo(
19 base::Bind(&SystemInfoStorageGetFunction::OnGetStorageInfoCompleted, 19 base::Bind(&SystemStorageGetInfoFunction::OnGetStorageInfoCompleted,
20 this)); 20 this));
21 return true; 21 return true;
22 } 22 }
23 23
24 void SystemInfoStorageGetFunction::OnGetStorageInfoCompleted(bool success) { 24 void SystemStorageGetInfoFunction::OnGetStorageInfoCompleted(bool success) {
25 if (success) { 25 if (success) {
26 results_ = 26 results_ = api::system_storage::GetInfo::Results::Create(
27 api::experimental_system_info_storage::Get::Results::Create( 27 StorageInfoProvider::Get()->storage_unit_info_list());
28 StorageInfoProvider::Get()->storage_unit_info_list());
29 } else { 28 } else {
30 SetError("Error occurred when querying storage information."); 29 SetError("Error occurred when querying storage information.");
31 } 30 }
32 31
33 SendResponse(success); 32 SendResponse(success);
34 } 33 }
35 34
36 SystemInfoStorageEjectDeviceFunction::~SystemInfoStorageEjectDeviceFunction() { 35 SystemStorageEjectDeviceFunction::~SystemStorageEjectDeviceFunction() {
37 } 36 }
38 37
39 bool SystemInfoStorageEjectDeviceFunction::RunImpl() { 38 bool SystemStorageEjectDeviceFunction::RunImpl() {
40 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 39 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
41 40
42 scoped_ptr<EjectDevice::Params> params(EjectDevice::Params::Create(*args_)); 41 scoped_ptr<EjectDevice::Params> params(EjectDevice::Params::Create(*args_));
43 EXTENSION_FUNCTION_VALIDATE(params.get()); 42 EXTENSION_FUNCTION_VALIDATE(params.get());
44 43
45 chrome::StorageMonitor::GetInstance()->EnsureInitialized(base::Bind( 44 chrome::StorageMonitor::GetInstance()->EnsureInitialized(base::Bind(
46 &SystemInfoStorageEjectDeviceFunction::OnStorageMonitorInit, 45 &SystemStorageEjectDeviceFunction::OnStorageMonitorInit,
47 this, 46 this,
48 params->id)); 47 params->id));
49 return true; 48 return true;
50 } 49 }
51 50
52 void SystemInfoStorageEjectDeviceFunction::OnStorageMonitorInit( 51 void SystemStorageEjectDeviceFunction::OnStorageMonitorInit(
53 const std::string& transient_device_id) { 52 const std::string& transient_device_id) {
54 DCHECK(chrome::StorageMonitor::GetInstance()->IsInitialized()); 53 DCHECK(chrome::StorageMonitor::GetInstance()->IsInitialized());
55 chrome::StorageMonitor* monitor = chrome::StorageMonitor::GetInstance(); 54 chrome::StorageMonitor* monitor = chrome::StorageMonitor::GetInstance();
56 std::string device_id_str = 55 std::string device_id_str =
57 StorageInfoProvider::Get()->GetDeviceIdForTransientId( 56 StorageInfoProvider::Get()->GetDeviceIdForTransientId(
58 transient_device_id); 57 transient_device_id);
59 58
60 if (device_id_str == "") { 59 if (device_id_str == "") {
61 HandleResponse(chrome::StorageMonitor::EJECT_NO_SUCH_DEVICE); 60 HandleResponse(chrome::StorageMonitor::EJECT_NO_SUCH_DEVICE);
62 return; 61 return;
63 } 62 }
64 63
65 monitor->EjectDevice( 64 monitor->EjectDevice(
66 device_id_str, 65 device_id_str,
67 base::Bind(&SystemInfoStorageEjectDeviceFunction::HandleResponse, 66 base::Bind(&SystemStorageEjectDeviceFunction::HandleResponse,
68 this)); 67 this));
69 } 68 }
70 69
71 void SystemInfoStorageEjectDeviceFunction::HandleResponse( 70 void SystemStorageEjectDeviceFunction::HandleResponse(
72 chrome::StorageMonitor::EjectStatus status) { 71 chrome::StorageMonitor::EjectStatus status) {
73 api::experimental_system_info_storage:: EjectDeviceResultCode result = 72 api::system_storage:: EjectDeviceResultCode result =
74 api::experimental_system_info_storage::EJECT_DEVICE_RESULT_CODE_FAILURE; 73 api::system_storage::EJECT_DEVICE_RESULT_CODE_FAILURE;
75 switch (status) { 74 switch (status) {
76 case chrome::StorageMonitor::EJECT_OK: 75 case chrome::StorageMonitor::EJECT_OK:
77 result = api::experimental_system_info_storage:: 76 result = api::system_storage::EJECT_DEVICE_RESULT_CODE_SUCCESS;
78 EJECT_DEVICE_RESULT_CODE_SUCCESS;
79 break; 77 break;
80 case chrome::StorageMonitor::EJECT_IN_USE: 78 case chrome::StorageMonitor::EJECT_IN_USE:
81 result = api::experimental_system_info_storage:: 79 result = api::system_storage::EJECT_DEVICE_RESULT_CODE_IN_USE;
82 EJECT_DEVICE_RESULT_CODE_IN_USE;
83 break; 80 break;
84 case chrome::StorageMonitor::EJECT_NO_SUCH_DEVICE: 81 case chrome::StorageMonitor::EJECT_NO_SUCH_DEVICE:
85 result = api::experimental_system_info_storage:: 82 result = api::system_storage::
86 EJECT_DEVICE_RESULT_CODE_NO_SUCH_DEVICE; 83 EJECT_DEVICE_RESULT_CODE_NO_SUCH_DEVICE;
87 break; 84 break;
88 case chrome::StorageMonitor::EJECT_FAILURE: 85 case chrome::StorageMonitor::EJECT_FAILURE:
89 result = api::experimental_system_info_storage:: 86 result = api::system_storage::EJECT_DEVICE_RESULT_CODE_FAILURE;
90 EJECT_DEVICE_RESULT_CODE_FAILURE;
91 } 87 }
92 88
93 SetResult(base::StringValue::CreateStringValue( 89 SetResult(base::StringValue::CreateStringValue(
94 api::experimental_system_info_storage::ToString(result))); 90 api::system_storage::ToString(result)));
95 SendResponse(true); 91 SendResponse(true);
96 } 92 }
97 93
98 SystemInfoStorageAddWatchFunction::SystemInfoStorageAddWatchFunction() { 94 SystemStorageAddAvailableCapacityWatchFunction::
95 SystemStorageAddAvailableCapacityWatchFunction() {
99 } 96 }
100 97
101 SystemInfoStorageAddWatchFunction::~SystemInfoStorageAddWatchFunction() { 98 SystemStorageAddAvailableCapacityWatchFunction::
99 ~SystemStorageAddAvailableCapacityWatchFunction() {
102 } 100 }
103 101
104 bool SystemInfoStorageAddWatchFunction::RunImpl() { 102 bool SystemStorageAddAvailableCapacityWatchFunction::RunImpl() {
105 // TODO(Haojian): Implement the addWatch api. 103 // TODO(Haojian): Implement the addAvailableCapacityWatch API.
106 return false; 104 return false;
107 } 105 }
108 106
109 SystemInfoStorageRemoveWatchFunction::SystemInfoStorageRemoveWatchFunction() { 107 SystemStorageRemoveAvailableCapacityWatchFunction::
108 SystemStorageRemoveAvailableCapacityWatchFunction() {
110 } 109 }
111 110
112 SystemInfoStorageRemoveWatchFunction::~SystemInfoStorageRemoveWatchFunction() { 111 SystemStorageRemoveAvailableCapacityWatchFunction::
112 ~SystemStorageRemoveAvailableCapacityWatchFunction() {
113 } 113 }
114 114
115 bool SystemInfoStorageRemoveWatchFunction::RunImpl() { 115 bool SystemStorageRemoveAvailableCapacityWatchFunction::RunImpl() {
116 // TODO(Haojian): Implement the removeWatch api. 116 // TODO(Haojian): Implement the removeAvailableCapacityWatch API.
117 return false; 117 return false;
118 } 118 }
119 119
120 SystemInfoStorageGetAllWatchFunction::SystemInfoStorageGetAllWatchFunction() { 120 SystemStorageGetAllAvailableCapacityWatchesFunction
121 ::SystemStorageGetAllAvailableCapacityWatchesFunction() {
121 } 122 }
122 123
123 SystemInfoStorageGetAllWatchFunction::~SystemInfoStorageGetAllWatchFunction() { 124 SystemStorageGetAllAvailableCapacityWatchesFunction
125 ::~SystemStorageGetAllAvailableCapacityWatchesFunction() {
124 } 126 }
125 127
126 bool SystemInfoStorageGetAllWatchFunction::RunImpl() { 128 bool SystemStorageGetAllAvailableCapacityWatchesFunction::RunImpl() {
127 // TODO(Haojian): Implement the getAllWatch api. 129 // TODO(Haojian): Implement the getAllAvailableCapacityWatches API.
128 return false; 130 return false;
129 } 131 }
130 132
131 SystemInfoStorageRemoveAllWatchFunction:: 133 SystemStorageRemoveAllAvailableCapacityWatchesFunction::
132 SystemInfoStorageRemoveAllWatchFunction() { 134 SystemStorageRemoveAllAvailableCapacityWatchesFunction() {
133 } 135 }
134 136
135 SystemInfoStorageRemoveAllWatchFunction:: 137 SystemStorageRemoveAllAvailableCapacityWatchesFunction::
136 ~SystemInfoStorageRemoveAllWatchFunction() { 138 ~SystemStorageRemoveAllAvailableCapacityWatchesFunction() {
137 } 139 }
138 140
139 bool SystemInfoStorageRemoveAllWatchFunction::RunImpl() { 141 bool SystemStorageRemoveAllAvailableCapacityWatchesFunction::RunImpl() {
140 // TODO(Haojian): Implement the removeAllWatch api. 142 // TODO(Haojian): Implement the removeAllAvailableCapacityWatches api.
141 return false; 143 return false;
142 } 144 }
143 145
144 } // namespace extensions 146 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698