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

Side by Side Diff: chrome/browser/browser_about_handler.cc

Issue 31014: Port DictionaryValue to use string16 instead of wstring. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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
« no previous file with comments | « chrome/browser/bookmarks/bookmark_html_writer.cc ('k') | chrome/browser/browser_init.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/browser_about_handler.h" 5 #include "chrome/browser/browser_about_handler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/file_version_info.h" 10 #include "base/file_version_info.h"
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 if (url->SchemeIs(chrome::kJavaScriptScheme)) 246 if (url->SchemeIs(chrome::kJavaScriptScheme))
247 return true; 247 return true;
248 return WebContents::SupportsURL(url); 248 return WebContents::SupportsURL(url);
249 } 249 }
250 250
251 251
252 // static 252 // static
253 std::string BrowserAboutHandler::AboutVersion() { 253 std::string BrowserAboutHandler::AboutVersion() {
254 // Strings used in the JsTemplate file. 254 // Strings used in the JsTemplate file.
255 DictionaryValue localized_strings; 255 DictionaryValue localized_strings;
256 localized_strings.SetString(L"title", 256 localized_strings.SetString(
257 l10n_util::GetString(IDS_ABOUT_VERSION_TITLE)); 257 ASCIIToUTF16("title"),
258 WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_VERSION_TITLE)));
258 scoped_ptr<FileVersionInfo> version_info( 259 scoped_ptr<FileVersionInfo> version_info(
259 FileVersionInfo::CreateFileVersionInfoForCurrentModule()); 260 FileVersionInfo::CreateFileVersionInfoForCurrentModule());
260 if (version_info == NULL) { 261 if (version_info == NULL) {
261 DLOG(ERROR) << "Unable to create FileVersionInfo object"; 262 DLOG(ERROR) << "Unable to create FileVersionInfo object";
262 return std::string(); 263 return std::string();
263 } 264 }
264 265
265 std::wstring webkit_version = UTF8ToWide(webkit_glue::GetWebKitVersion()); 266 std::wstring webkit_version = UTF8ToWide(webkit_glue::GetWebKitVersion());
266 #ifdef CHROME_V8 267 #ifdef CHROME_V8
267 const char* v8_vers = v8::V8::GetVersion(); 268 const char* v8_vers = v8::V8::GetVersion();
268 std::wstring js_version = UTF8ToWide(v8_vers); 269 std::wstring js_version = UTF8ToWide(v8_vers);
269 std::wstring js_engine = L"V8"; 270 std::wstring js_engine = L"V8";
270 #else 271 #else
271 std::wstring js_version = webkit_version; 272 std::wstring js_version = webkit_version;
272 std::wstring js_engine = L"JavaScriptCore"; 273 std::wstring js_engine = L"JavaScriptCore";
273 #endif 274 #endif
274 275
275 localized_strings.SetString(L"name", 276 localized_strings.SetString(
276 l10n_util::GetString(IDS_PRODUCT_NAME)); 277 ASCIIToUTF16("name"),
277 localized_strings.SetString(L"version", version_info->file_version()); 278 WideToUTF16Hack(l10n_util::GetString(IDS_PRODUCT_NAME)));
278 localized_strings.SetString(L"js_engine", js_engine); 279 localized_strings.SetString(ASCIIToUTF16("version"),
279 localized_strings.SetString(L"js_version", js_version); 280 WideToUTF16Hack(version_info->file_version()));
280 localized_strings.SetString(L"webkit_version", webkit_version); 281 localized_strings.SetString(ASCIIToUTF16("js_engine"),
281 localized_strings.SetString(L"company", 282 WideToUTF16Hack(js_engine));
282 l10n_util::GetString(IDS_ABOUT_VERSION_COMPANY_NAME)); 283 localized_strings.SetString(ASCIIToUTF16("js_version"),
283 localized_strings.SetString(L"copyright", 284 WideToUTF16Hack(js_version));
284 l10n_util::GetString(IDS_ABOUT_VERSION_COPYRIGHT)); 285 localized_strings.SetString(ASCIIToUTF16("webkit_version"),
285 localized_strings.SetString(L"cl", version_info->last_change()); 286 WideToUTF16Hack(webkit_version));
287 localized_strings.SetString(
288 ASCIIToUTF16("company"),
289 WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_VERSION_COMPANY_NAME)));
290 localized_strings.SetString(
291 ASCIIToUTF16("copyright"),
292 WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_VERSION_COPYRIGHT)));
293 localized_strings.SetString(ASCIIToUTF16("cl"),
294 WideToUTF16Hack(version_info->last_change()));
286 if (version_info->is_official_build()) { 295 if (version_info->is_official_build()) {
287 localized_strings.SetString(L"official", 296 localized_strings.SetString(
288 l10n_util::GetString(IDS_ABOUT_VERSION_OFFICIAL)); 297 ASCIIToUTF16("official"),
298 WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_VERSION_OFFICIAL)));
289 } else { 299 } else {
290 localized_strings.SetString(L"official", 300 localized_strings.SetString(
291 l10n_util::GetString(IDS_ABOUT_VERSION_UNOFFICIAL)); 301 ASCIIToUTF16("official"),
302 WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_VERSION_UNOFFICIAL)));
292 } 303 }
293 localized_strings.SetString(L"useragent", 304 localized_strings.SetString(ASCIIToUTF16("useragent"),
294 UTF8ToWide(webkit_glue::GetUserAgent(GURL()))); 305 UTF8ToUTF16(webkit_glue::GetUserAgent(GURL())));
295 306
296 static const StringPiece version_html( 307 static const StringPiece version_html(
297 ResourceBundle::GetSharedInstance().GetRawDataResource( 308 ResourceBundle::GetSharedInstance().GetRawDataResource(
298 IDR_ABOUT_VERSION_HTML)); 309 IDR_ABOUT_VERSION_HTML));
299 310
300 return jstemplate_builder::GetTemplateHtml( 311 return jstemplate_builder::GetTemplateHtml(
301 version_html, &localized_strings, "t" /* template root node id */); 312 version_html, &localized_strings, "t" /* template root node id */);
302 } 313 }
303 314
304 // static 315 // static
(...skipping 20 matching lines...) Expand all
325 ResourceBundle::GetSharedInstance().GetDataResource( 336 ResourceBundle::GetSharedInstance().GetDataResource(
326 IDR_TERMS_HTML); 337 IDR_TERMS_HTML);
327 338
328 return terms_html; 339 return terms_html;
329 } 340 }
330 341
331 // static 342 // static
332 std::string BrowserAboutHandler::AboutPlugins() { 343 std::string BrowserAboutHandler::AboutPlugins() {
333 // Strings used in the JsTemplate file. 344 // Strings used in the JsTemplate file.
334 DictionaryValue localized_strings; 345 DictionaryValue localized_strings;
335 localized_strings.SetString(L"title", 346 localized_strings.SetString(
336 l10n_util::GetString(IDS_ABOUT_PLUGINS_TITLE)); 347 ASCIIToUTF16("title"),
337 localized_strings.SetString(L"headingPlugs", 348 WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_TITLE)));
338 l10n_util::GetString(IDS_ABOUT_PLUGINS_HEADING_PLUGS)); 349 localized_strings.SetString(
339 localized_strings.SetString(L"headingNoPlugs", 350 ASCIIToUTF16("headingPlugs"),
340 l10n_util::GetString(IDS_ABOUT_PLUGINS_HEADING_NOPLUGS)); 351 WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_HEADING_PLUGS)));
341 localized_strings.SetString(L"filename", 352 localized_strings.SetString(
342 l10n_util::GetString(IDS_ABOUT_PLUGINS_FILENAME_LABEL)); 353 ASCIIToUTF16("headingNoPlugs"),
343 localized_strings.SetString(L"mimetype", 354 WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_HEADING_NOPLUGS)));
344 l10n_util::GetString(IDS_ABOUT_PLUGINS_MIMETYPE_LABEL)); 355 localized_strings.SetString(
345 localized_strings.SetString(L"description", 356 ASCIIToUTF16("filename"),
346 l10n_util::GetString(IDS_ABOUT_PLUGINS_DESCRIPTION_LABEL)); 357 WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_FILENAME_LABEL)));
347 localized_strings.SetString(L"suffixes", 358 localized_strings.SetString(
348 l10n_util::GetString(IDS_ABOUT_PLUGINS_SUFFIX_LABEL)); 359 ASCIIToUTF16("mimetype"),
349 localized_strings.SetString(L"enabled", 360 WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_MIMETYPE_LABEL)));
350 l10n_util::GetString(IDS_ABOUT_PLUGINS_ENABLED_LABEL)); 361 localized_strings.SetString(
351 localized_strings.SetString(L"enabled_yes", 362 ASCIIToUTF16("description"),
352 l10n_util::GetString(IDS_ABOUT_PLUGINS_ENABLED_YES)); 363 WideToUTF16Hack(
353 localized_strings.SetString(L"enabled_no", 364 l10n_util::GetString(IDS_ABOUT_PLUGINS_DESCRIPTION_LABEL)));
354 l10n_util::GetString(IDS_ABOUT_PLUGINS_ENABLED_NO)); 365 localized_strings.SetString(
366 ASCIIToUTF16("suffixes"),
367 WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_SUFFIX_LABEL)));
368 localized_strings.SetString(
369 ASCIIToUTF16("enabled"),
370 WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_ENABLED_LABEL)));
371 localized_strings.SetString(
372 ASCIIToUTF16("enabled_yes"),
373 WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_ENABLED_YES)));
374 localized_strings.SetString(
375 ASCIIToUTF16("enabled_no"),
376 WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_ENABLED_NO)));
355 377
356 static const StringPiece plugins_html( 378 static const StringPiece plugins_html(
357 ResourceBundle::GetSharedInstance().GetRawDataResource( 379 ResourceBundle::GetSharedInstance().GetRawDataResource(
358 IDR_ABOUT_PLUGINS_HTML)); 380 IDR_ABOUT_PLUGINS_HTML));
359 381
360 return jstemplate_builder::GetTemplateHtml( 382 return jstemplate_builder::GetTemplateHtml(
361 plugins_html, &localized_strings, "t" /* template root node id */); 383 plugins_html, &localized_strings, "t" /* template root node id */);
362 } 384 }
363 385
364 // static 386 // static
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 // stats computations across runs. 419 // stats computations across runs.
398 static DictionaryValue root; 420 static DictionaryValue root;
399 421
400 StatsTable* table = StatsTable::current(); 422 StatsTable* table = StatsTable::current();
401 if (!table) 423 if (!table)
402 return std::string(); 424 return std::string();
403 425
404 // We maintain two lists - one for counters and one for timers. 426 // We maintain two lists - one for counters and one for timers.
405 // Timers actually get stored on both lists. 427 // Timers actually get stored on both lists.
406 ListValue* counters; 428 ListValue* counters;
407 if (!root.GetList(L"counters", &counters)) { 429 if (!root.GetList(ASCIIToUTF16("counters"), &counters)) {
408 counters = new ListValue(); 430 counters = new ListValue();
409 root.Set(L"counters", counters); 431 root.Set(ASCIIToUTF16("counters"), counters);
410 } 432 }
411 433
412 ListValue* timers; 434 ListValue* timers;
413 if (!root.GetList(L"timers", &timers)) { 435 if (!root.GetList(ASCIIToUTF16("timers"), &timers)) {
414 timers = new ListValue(); 436 timers = new ListValue();
415 root.Set(L"timers", timers); 437 root.Set(ASCIIToUTF16("timers"), timers);
416 } 438 }
417 439
418 // NOTE: Counters start at index 1. 440 // NOTE: Counters start at index 1.
419 for (int index = 1; index <= table->GetMaxCounters(); index++) { 441 for (int index = 1; index <= table->GetMaxCounters(); index++) {
420 // Get the counter's full name 442 // Get the counter's full name
421 std::string full_name = table->GetRowName(index); 443 std::string full_name = table->GetRowName(index);
422 if (full_name.length() == 0) 444 if (full_name.length() == 0)
423 break; 445 break;
424 DCHECK(full_name[1] == ':'); 446 DCHECK(full_name[1] == ':');
425 char counter_type = full_name[0]; 447 char counter_type = full_name[0];
426 std::string name = full_name.substr(2); 448 std::string name = full_name.substr(2);
427 449
428 // JSON doesn't allow '.' in names. 450 // JSON doesn't allow '.' in names.
429 size_t pos; 451 size_t pos;
430 while ((pos = name.find(".")) != std::string::npos) 452 while ((pos = name.find(".")) != std::string::npos)
431 name.replace(pos, 1, ":"); 453 name.replace(pos, 1, ":");
432 454
433 // Try to see if this name already exists. 455 // Try to see if this name already exists.
434 DictionaryValue* counter = NULL; 456 DictionaryValue* counter = NULL;
435 for (size_t scan_index = 0; 457 for (size_t scan_index = 0;
436 scan_index < counters->GetSize(); scan_index++) { 458 scan_index < counters->GetSize(); scan_index++) {
437 DictionaryValue* dictionary; 459 DictionaryValue* dictionary;
438 if (counters->GetDictionary(scan_index, &dictionary)) { 460 if (counters->GetDictionary(scan_index, &dictionary)) {
439 std::wstring scan_name; 461 string16 scan_name;
440 if (dictionary->GetString(L"name", &scan_name) && 462 if (dictionary->GetString(ASCIIToUTF16("name"), &scan_name) &&
441 WideToASCII(scan_name) == name) { 463 UTF16ToUTF8(scan_name) == name) {
442 counter = dictionary; 464 counter = dictionary;
443 } 465 }
444 } else { 466 } else {
445 NOTREACHED(); // Should always be there 467 NOTREACHED(); // Should always be there
446 } 468 }
447 } 469 }
448 470
449 if (counter == NULL) { 471 if (counter == NULL) {
450 counter = new DictionaryValue(); 472 counter = new DictionaryValue();
451 counter->SetString(L"name", ASCIIToWide(name)); 473 counter->SetString(ASCIIToUTF16("name"), UTF8ToUTF16(name));
452 counters->Append(counter); 474 counters->Append(counter);
453 } 475 }
454 476
455 switch (counter_type) { 477 switch (counter_type) {
456 case 'c': 478 case 'c':
457 { 479 {
458 int new_value = table->GetRowValue(index); 480 int new_value = table->GetRowValue(index);
459 int prior_value = 0; 481 int prior_value = 0;
460 int delta = 0; 482 int delta = 0;
461 if (counter->GetInteger(L"value", &prior_value)) { 483 if (counter->GetInteger(ASCIIToUTF16("value"), &prior_value)) {
462 delta = new_value - prior_value; 484 delta = new_value - prior_value;
463 } 485 }
464 counter->SetInteger(L"value", new_value); 486 counter->SetInteger(ASCIIToUTF16("value"), new_value);
465 counter->SetInteger(L"delta", delta); 487 counter->SetInteger(ASCIIToUTF16("delta"), delta);
466 } 488 }
467 break; 489 break;
468 case 'm': 490 case 'm':
469 { 491 {
470 // TODO(mbelshe): implement me. 492 // TODO(mbelshe): implement me.
471 } 493 }
472 break; 494 break;
473 case 't': 495 case 't':
474 { 496 {
475 int time = table->GetRowValue(index); 497 int time = table->GetRowValue(index);
476 counter->SetInteger(L"time", time); 498 counter->SetInteger(ASCIIToUTF16("time"), time);
477 499
478 // Store this on the timers list as well. 500 // Store this on the timers list as well.
479 timers->Append(counter); 501 timers->Append(counter);
480 } 502 }
481 break; 503 break;
482 default: 504 default:
483 NOTREACHED(); 505 NOTREACHED();
484 } 506 }
485 } 507 }
486 508
(...skipping 25 matching lines...) Expand all
512 } 534 }
513 535
514 // Helper for AboutMemory to bind results from a ProcessMetrics object 536 // Helper for AboutMemory to bind results from a ProcessMetrics object
515 // to a DictionaryValue. Fills ws_usage and comm_usage so that the objects 537 // to a DictionaryValue. Fills ws_usage and comm_usage so that the objects
516 // can be used in caller's scope (e.g for appending to a net total). 538 // can be used in caller's scope (e.g for appending to a net total).
517 void AboutMemoryHandler::BindProcessMetrics(DictionaryValue* data, 539 void AboutMemoryHandler::BindProcessMetrics(DictionaryValue* data,
518 ProcessMemoryInformation* info) { 540 ProcessMemoryInformation* info) {
519 DCHECK(data && info); 541 DCHECK(data && info);
520 542
521 // Bind metrics to dictionary. 543 // Bind metrics to dictionary.
522 data->SetInteger(L"ws_priv", static_cast<int>(info->working_set.priv)); 544 data->SetInteger(ASCIIToUTF16("ws_priv"),
523 data->SetInteger(L"ws_shareable", 545 static_cast<int>(info->working_set.priv));
546 data->SetInteger(ASCIIToUTF16("ws_shareable"),
524 static_cast<int>(info->working_set.shareable)); 547 static_cast<int>(info->working_set.shareable));
525 data->SetInteger(L"ws_shared", static_cast<int>(info->working_set.shared)); 548 data->SetInteger(ASCIIToUTF16("ws_shared"),
526 data->SetInteger(L"comm_priv", static_cast<int>(info->committed.priv)); 549 static_cast<int>(info->working_set.shared));
527 data->SetInteger(L"comm_map", static_cast<int>(info->committed.mapped)); 550 data->SetInteger(ASCIIToUTF16("comm_priv"),
528 data->SetInteger(L"comm_image", static_cast<int>(info->committed.image)); 551 static_cast<int>(info->committed.priv));
529 data->SetInteger(L"pid", info->pid); 552 data->SetInteger(ASCIIToUTF16("comm_map"),
530 data->SetString(L"version", info->version); 553 static_cast<int>(info->committed.mapped));
531 data->SetInteger(L"processes", info->num_processes); 554 data->SetInteger(ASCIIToUTF16("comm_image"),
555 static_cast<int>(info->committed.image));
556 data->SetInteger(ASCIIToUTF16("pid"), info->pid);
557 data->SetString(ASCIIToUTF16("version"), WideToUTF16Hack(info->version));
558 data->SetInteger(ASCIIToUTF16("processes"), info->num_processes);
532 } 559 }
533 560
534 // Helper for AboutMemory to append memory usage information for all 561 // Helper for AboutMemory to append memory usage information for all
535 // sub-processes (i.e. renderers, plugins) used by Chrome. 562 // sub-processes (i.e. renderers, plugins) used by Chrome.
536 void AboutMemoryHandler::AppendProcess(ListValue* child_data, 563 void AboutMemoryHandler::AppendProcess(ListValue* child_data,
537 ProcessMemoryInformation* info) { 564 ProcessMemoryInformation* info) {
538 DCHECK(child_data && info); 565 DCHECK(child_data && info);
539 566
540 // Append a new DictionaryValue for this renderer to our list. 567 // Append a new DictionaryValue for this renderer to our list.
541 DictionaryValue* child = new DictionaryValue(); 568 DictionaryValue* child = new DictionaryValue();
542 child_data->Append(child); 569 child_data->Append(child);
543 BindProcessMetrics(child, info); 570 BindProcessMetrics(child, info);
544 571
545 std::wstring child_label(ChildProcessInfo::GetTypeNameInEnglish(info->type)); 572 std::wstring child_label(ChildProcessInfo::GetTypeNameInEnglish(info->type));
546 if (info->is_diagnostics) 573 if (info->is_diagnostics)
547 child_label.append(L" (diagnostics)"); 574 child_label.append(L" (diagnostics)");
548 child->SetString(L"child_name", child_label); 575 child->SetString(ASCIIToUTF16("child_name"), WideToUTF16Hack(child_label));
549 ListValue* titles = new ListValue(); 576 ListValue* titles = new ListValue();
550 child->Set(L"titles", titles); 577 child->Set(ASCIIToUTF16("titles"), titles);
551 for (size_t i = 0; i < info->titles.size(); ++i) 578 for (size_t i = 0; i < info->titles.size(); ++i)
552 titles->Append(new StringValue(info->titles[i])); 579 titles->Append(new StringValue(info->titles[i]));
553 } 580 }
554 581
555 582
556 void AboutMemoryHandler::OnDetailsAvailable() { 583 void AboutMemoryHandler::OnDetailsAvailable() {
557 // the root of the JSON hierarchy for about:memory jstemplate 584 // the root of the JSON hierarchy for about:memory jstemplate
558 DictionaryValue root; 585 DictionaryValue root;
559 ListValue* browsers = new ListValue(); 586 ListValue* browsers = new ListValue();
560 root.Set(L"browsers", browsers); 587 root.Set(ASCIIToUTF16("browsers"), browsers);
561 588
562 ProcessData* browser_processes = processes(); 589 ProcessData* browser_processes = processes();
563 590
564 // Aggregate per-process data into browser summary data. 591 // Aggregate per-process data into browser summary data.
565 std::wstring log_string; 592 std::wstring log_string;
566 for (int index = 0; index < MemoryDetails::MAX_BROWSERS; index++) { 593 for (int index = 0; index < MemoryDetails::MAX_BROWSERS; index++) {
567 if (browser_processes[index].processes.size() == 0) 594 if (browser_processes[index].processes.size() == 0)
568 continue; 595 continue;
569 596
570 // Sum the information for the processes within this browser. 597 // Sum the information for the processes within this browser.
(...skipping 10 matching lines...) Expand all
581 aggregate.working_set.shareable += iterator->working_set.shareable; 608 aggregate.working_set.shareable += iterator->working_set.shareable;
582 aggregate.committed.priv += iterator->committed.priv; 609 aggregate.committed.priv += iterator->committed.priv;
583 aggregate.committed.mapped += iterator->committed.mapped; 610 aggregate.committed.mapped += iterator->committed.mapped;
584 aggregate.committed.image += iterator->committed.image; 611 aggregate.committed.image += iterator->committed.image;
585 aggregate.num_processes++; 612 aggregate.num_processes++;
586 } 613 }
587 ++iterator; 614 ++iterator;
588 } 615 }
589 DictionaryValue* browser_data = new DictionaryValue(); 616 DictionaryValue* browser_data = new DictionaryValue();
590 browsers->Append(browser_data); 617 browsers->Append(browser_data);
591 browser_data->SetString(L"name", browser_processes[index].name); 618 browser_data->SetString(ASCIIToUTF16("name"),
619 WideToUTF16Hack(browser_processes[index].name));
592 620
593 BindProcessMetrics(browser_data, &aggregate); 621 BindProcessMetrics(browser_data, &aggregate);
594 622
595 // We log memory info as we record it. 623 // We log memory info as we record it.
596 if (log_string.length() > 0) 624 if (log_string.length() > 0)
597 log_string.append(L", "); 625 log_string.append(L", ");
598 log_string.append(browser_processes[index].name); 626 log_string.append(browser_processes[index].name);
599 log_string.append(L", "); 627 log_string.append(L", ");
600 log_string.append(Int64ToWString(aggregate.working_set.priv)); 628 log_string.append(Int64ToWString(aggregate.working_set.priv));
601 log_string.append(L", "); 629 log_string.append(L", ");
602 log_string.append(Int64ToWString(aggregate.working_set.shared)); 630 log_string.append(Int64ToWString(aggregate.working_set.shared));
603 log_string.append(L", "); 631 log_string.append(L", ");
604 log_string.append(Int64ToWString(aggregate.working_set.shareable)); 632 log_string.append(Int64ToWString(aggregate.working_set.shareable));
605 } 633 }
606 if (log_string.length() > 0) 634 if (log_string.length() > 0)
607 LOG(INFO) << "memory: " << log_string; 635 LOG(INFO) << "memory: " << log_string;
608 636
609 // Set the browser & renderer detailed process data. 637 // Set the browser & renderer detailed process data.
610 DictionaryValue* browser_data = new DictionaryValue(); 638 DictionaryValue* browser_data = new DictionaryValue();
611 root.Set(L"browzr_data", browser_data); 639 root.Set(ASCIIToUTF16("browzr_data"), browser_data);
612 ListValue* child_data = new ListValue(); 640 ListValue* child_data = new ListValue();
613 root.Set(L"child_data", child_data); 641 root.Set(ASCIIToUTF16("child_data"), child_data);
614 642
615 ProcessData process = browser_processes[0]; // Chrome is the first browser. 643 ProcessData process = browser_processes[0]; // Chrome is the first browser.
616 for (size_t index = 0; index < process.processes.size(); index++) { 644 for (size_t index = 0; index < process.processes.size(); index++) {
617 if (process.processes[index].type == ChildProcessInfo::BROWSER_PROCESS) 645 if (process.processes[index].type == ChildProcessInfo::BROWSER_PROCESS)
618 BindProcessMetrics(browser_data, &process.processes[index]); 646 BindProcessMetrics(browser_data, &process.processes[index]);
619 else 647 else
620 AppendProcess(child_data, &process.processes[index]); 648 AppendProcess(child_data, &process.processes[index]);
621 } 649 }
622 650
623 // Get about_memory.html 651 // Get about_memory.html
624 static const StringPiece memory_html( 652 static const StringPiece memory_html(
625 ResourceBundle::GetSharedInstance().GetRawDataResource( 653 ResourceBundle::GetSharedInstance().GetRawDataResource(
626 IDR_ABOUT_MEMORY_HTML)); 654 IDR_ABOUT_MEMORY_HTML));
627 655
628 // Create jstemplate and return. 656 // Create jstemplate and return.
629 std::string template_html = jstemplate_builder::GetTemplateHtml( 657 std::string template_html = jstemplate_builder::GetTemplateHtml(
630 memory_html, &root, "t" /* template root node id */); 658 memory_html, &root, "t" /* template root node id */);
631 659
632 AboutSource* about_source = static_cast<AboutSource*>(source_); 660 AboutSource* about_source = static_cast<AboutSource*>(source_);
633 about_source->FinishDataRequest(template_html, request_id_); 661 about_source->FinishDataRequest(template_html, request_id_);
634 } 662 }
635 663
636 // static 664 // static
637 void BrowserAboutHandler::AboutMemory(AboutSource* source, int request_id) { 665 void BrowserAboutHandler::AboutMemory(AboutSource* source, int request_id) {
638 // The AboutMemoryHandler cleans itself up. 666 // The AboutMemoryHandler cleans itself up.
639 new AboutMemoryHandler(source, request_id); 667 new AboutMemoryHandler(source, request_id);
640 } 668 }
OLDNEW
« no previous file with comments | « chrome/browser/bookmarks/bookmark_html_writer.cc ('k') | chrome/browser/browser_init.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698