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

Side by Side Diff: chrome/browser/ui/webui/chromeos/drive_internals_ui.cc

Issue 11106009: drive: Add the local largest changestamp to chrome:drive-internals (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 8 years, 2 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 | Annotate | Revision Log
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 4
5 #include "chrome/browser/ui/webui/chromeos/drive_internals_ui.h" 5 #include "chrome/browser/ui/webui/chromeos/drive_internals_ui.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/string_number_conversions.h"
14 #include "base/stringprintf.h" 13 #include "base/stringprintf.h"
15 #include "base/sys_info.h" 14 #include "base/sys_info.h"
16 #include "chrome/browser/chromeos/drive/drive.pb.h" 15 #include "chrome/browser/chromeos/drive/drive.pb.h"
17 #include "chrome/browser/chromeos/drive/drive_cache.h" 16 #include "chrome/browser/chromeos/drive/drive_cache.h"
18 #include "chrome/browser/chromeos/drive/drive_file_system_interface.h" 17 #include "chrome/browser/chromeos/drive/drive_file_system_interface.h"
18 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h"
19 #include "chrome/browser/chromeos/drive/drive_system_service.h" 19 #include "chrome/browser/chromeos/drive/drive_system_service.h"
20 #include "chrome/browser/google_apis/auth_service.h" 20 #include "chrome/browser/google_apis/auth_service.h"
21 #include "chrome/browser/google_apis/drive_api_parser.h" 21 #include "chrome/browser/google_apis/drive_api_parser.h"
22 #include "chrome/browser/google_apis/drive_service_interface.h" 22 #include "chrome/browser/google_apis/drive_service_interface.h"
23 #include "chrome/browser/google_apis/gdata_errorcode.h" 23 #include "chrome/browser/google_apis/gdata_errorcode.h"
24 #include "chrome/browser/google_apis/gdata_util.h" 24 #include "chrome/browser/google_apis/gdata_util.h"
25 #include "chrome/browser/google_apis/gdata_wapi_parser.h" 25 #include "chrome/browser/google_apis/gdata_wapi_parser.h"
26 #include "chrome/browser/profiles/profile.h" 26 #include "chrome/browser/profiles/profile.h"
27 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" 27 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
28 #include "chrome/common/url_constants.h" 28 #include "chrome/common/url_constants.h"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 base::DictionaryValue account_metadata; 230 base::DictionaryValue account_metadata;
231 231
232 if (gdata::util::IsDriveV2ApiEnabled()) { 232 if (gdata::util::IsDriveV2ApiEnabled()) {
233 scoped_ptr<gdata::AboutResource> about_resource; 233 scoped_ptr<gdata::AboutResource> about_resource;
234 about_resource = gdata::AboutResource::CreateFrom(*data); 234 about_resource = gdata::AboutResource::CreateFrom(*data);
235 235
236 account_metadata.SetDouble("account-quota-total", 236 account_metadata.SetDouble("account-quota-total",
237 about_resource->quota_bytes_total()); 237 about_resource->quota_bytes_total());
238 account_metadata.SetDouble("account-quota-used", 238 account_metadata.SetDouble("account-quota-used",
239 about_resource->quota_bytes_used()); 239 about_resource->quota_bytes_used());
240 account_metadata.SetString( 240 account_metadata.SetDouble("account-largest-changestamp-remote",
241 "account-largest-changestamp", 241 about_resource->largest_change_id());
242 base::Int64ToString(about_resource->largest_change_id()));
243 242
244 // TODO(haruki): Fill installed Drive apps for Drive API. 243 // TODO(haruki): Fill installed Drive apps for Drive API.
245 // http://crbug.com/154241 244 // http://crbug.com/154241
246 return; 245 return;
247 } else { 246 } else {
248 scoped_ptr<gdata::AccountMetadataFeed> feed; 247 scoped_ptr<gdata::AccountMetadataFeed> feed;
249 feed = gdata::AccountMetadataFeed::CreateFrom(*data); 248 feed = gdata::AccountMetadataFeed::CreateFrom(*data);
250 249
251 account_metadata.SetDouble("account-quota-total", 250 account_metadata.SetDouble("account-quota-total",
252 feed->quota_bytes_total()); 251 feed->quota_bytes_total());
253 account_metadata.SetDouble("account-quota-used", feed->quota_bytes_used()); 252 account_metadata.SetDouble("account-quota-used", feed->quota_bytes_used());
254 account_metadata.SetString( 253 account_metadata.SetDouble("account-largest-changestamp-remote",
255 "account-largest-changestamp", 254 feed->largest_changestamp());
256 base::Int64ToString(feed->largest_changestamp()));
257 255
258 base::ListValue* installed_apps = new base::ListValue(); 256 base::ListValue* installed_apps = new base::ListValue();
259 for (size_t i = 0; i < feed->installed_apps().size(); ++i) { 257 for (size_t i = 0; i < feed->installed_apps().size(); ++i) {
260 const gdata::InstalledApp* app = feed->installed_apps()[i]; 258 const gdata::InstalledApp* app = feed->installed_apps()[i];
261 base::DictionaryValue* app_data = new base::DictionaryValue(); 259 base::DictionaryValue* app_data = new base::DictionaryValue();
262 app_data->SetString("app_name", app->app_name()); 260 app_data->SetString("app_name", app->app_name());
263 app_data->SetString("app_id", app->app_id()); 261 app_data->SetString("app_id", app->app_id());
264 app_data->SetString("object_type", app->object_type()); 262 app_data->SetString("object_type", app->object_type());
265 app_data->SetBoolean("supports_create", app->supports_create()); 263 app_data->SetBoolean("supports_create", app->supports_create());
266 264
267 installed_apps->Append(app_data); 265 installed_apps->Append(app_data);
268 } 266 }
269 account_metadata.Set("installed-apps", installed_apps); 267 account_metadata.Set("installed-apps", installed_apps);
270 } 268 }
271 269
270 // Add the local largest chargestamp.
271 const drive::DriveFileSystemMetadata metadata =
272 GetSystemService()->file_system()->GetMetadata();
273 account_metadata.SetDouble("account-largest-changestamp-local",
274 metadata.largest_changestamp);
275
272 web_ui()->CallJavascriptFunction("updateAccountMetadata", account_metadata); 276 web_ui()->CallJavascriptFunction("updateAccountMetadata", account_metadata);
273 } 277 }
274 278
275 void DriveInternalsWebUIHandler::RegisterMessages() { 279 void DriveInternalsWebUIHandler::RegisterMessages() {
276 web_ui()->RegisterMessageCallback( 280 web_ui()->RegisterMessageCallback(
277 "pageLoaded", 281 "pageLoaded",
278 base::Bind(&DriveInternalsWebUIHandler::OnPageLoaded, 282 base::Bind(&DriveInternalsWebUIHandler::OnPageLoaded,
279 weak_ptr_factory_.GetWeakPtr())); 283 weak_ptr_factory_.GetWeakPtr()));
280 web_ui()->RegisterMessageCallback( 284 web_ui()->RegisterMessageCallback(
281 "periodicUpdate", 285 "periodicUpdate",
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 new ChromeWebUIDataSource(chrome::kChromeUIDriveInternalsHost); 512 new ChromeWebUIDataSource(chrome::kChromeUIDriveInternalsHost);
509 source->add_resource_path("drive_internals.css", IDR_DRIVE_INTERNALS_CSS); 513 source->add_resource_path("drive_internals.css", IDR_DRIVE_INTERNALS_CSS);
510 source->add_resource_path("drive_internals.js", IDR_DRIVE_INTERNALS_JS); 514 source->add_resource_path("drive_internals.js", IDR_DRIVE_INTERNALS_JS);
511 source->set_default_resource(IDR_DRIVE_INTERNALS_HTML); 515 source->set_default_resource(IDR_DRIVE_INTERNALS_HTML);
512 516
513 Profile* profile = Profile::FromWebUI(web_ui); 517 Profile* profile = Profile::FromWebUI(web_ui);
514 ChromeURLDataManager::AddDataSource(profile, source); 518 ChromeURLDataManager::AddDataSource(profile, source);
515 } 519 }
516 520
517 } // namespace chromeos 521 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698