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

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

Issue 7983042: CrOS: Add Discard Tab command link to about:discards (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: revert tab_strip_model.h Created 9 years, 3 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 | « no previous file | chrome/browser/oom_priority_manager.h » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 669
670 return output; 670 return output;
671 } 671 }
672 672
673 std::string AboutCryptohome(const std::string& query) { 673 std::string AboutCryptohome(const std::string& query) {
674 int refresh; 674 int refresh;
675 base::StringToInt(query, &refresh); 675 base::StringToInt(query, &refresh);
676 return GetCryptohomeHtmlInfo(refresh); 676 return GetCryptohomeHtmlInfo(refresh);
677 } 677 }
678 678
679 std::string AboutDiscards() { 679 std::string AboutDiscards(const std::string& path) {
680 std::string output; 680 std::string output;
681 const std::string kRunCommand("run");
682 if (path == kRunCommand) {
683 output.append(WrapWithTag("p", "Discarding a tab..."));
684 g_browser_process->oom_priority_manager()->DiscardTab();
685 }
681 AppendHeader(&output, 0, "About discards"); 686 AppendHeader(&output, 0, "About discards");
682 AppendBody(&output); 687 AppendBody(&output);
683 output.append("<h3>About discards</h3>"); 688 output.append("<h3>About discards</h3>");
684 output.append( 689 output.append(
685 "<p>Tabs sorted from most interesting to least interesting. The least " 690 "<p>Tabs sorted from most interesting to least interesting. The least "
686 "interesting tab may be discarded if we run out of physical memory.</p>"); 691 "interesting tab may be discarded if we run out of physical memory.</p>");
687 692
688 std::vector<string16> titles = 693 std::vector<string16> titles =
689 g_browser_process->oom_priority_manager()->GetTabTitles(); 694 g_browser_process->oom_priority_manager()->GetTabTitles();
690 if (!titles.empty()) { 695 if (!titles.empty()) {
691 output.append("<ol>"); 696 output.append("<ol>");
692 std::vector<string16>::iterator it = titles.begin(); 697 std::vector<string16>::iterator it = titles.begin();
693 for ( ; it != titles.end(); ++it) { 698 for ( ; it != titles.end(); ++it) {
694 std::string title = UTF16ToUTF8(*it); 699 std::string title = UTF16ToUTF8(*it);
695 output.append(WrapWithTag("li", title)); 700 output.append(WrapWithTag("li", title));
696 } 701 }
697 output.append("</ol>"); 702 output.append("</ol>");
698 } else { 703 } else {
699 output.append("<p>None found. Wait 10 seconds, then refresh.</p>"); 704 output.append("<p>None found. Wait 10 seconds, then refresh.</p>");
700 } 705 }
706 output.append(
707 "<a href='chrome://discards/" + kRunCommand + "'>Discard tab now</a>");
701 708
702 base::SystemMemoryInfoKB meminfo; 709 base::SystemMemoryInfoKB meminfo;
703 base::GetSystemMemoryInfo(&meminfo); 710 base::GetSystemMemoryInfo(&meminfo);
704 output.append("<h3>System memory information in MB</h3>"); 711 output.append("<h3>System memory information in MB</h3>");
705 output.append("<table>"); 712 output.append("<table>");
706 output.append(AddStringRow( 713 output.append(AddStringRow(
707 "Total Memory", base::IntToString(meminfo.total / 1024))); 714 "Total", base::IntToString(meminfo.total / 1024)));
708 output.append(AddStringRow( 715 output.append(AddStringRow(
709 "Free Memory", base::IntToString(meminfo.free / 1024))); 716 "Free", base::IntToString(meminfo.free / 1024)));
710 output.append(AddStringRow( 717 output.append(AddStringRow(
711 "Buffered Memory", base::IntToString(meminfo.buffers / 1024))); 718 "Buffered", base::IntToString(meminfo.buffers / 1024)));
712 output.append(AddStringRow( 719 output.append(AddStringRow(
713 "Cached Memory", base::IntToString(meminfo.cached / 1024))); 720 "Cached", base::IntToString(meminfo.cached / 1024)));
714 output.append(AddStringRow( 721 output.append(AddStringRow(
715 "Committed Memory", base::IntToString( 722 "Committed", base::IntToString(
716 (meminfo.total - meminfo.free - meminfo.buffers - meminfo.cached) / 1024))); 723 (meminfo.total - meminfo.free - meminfo.buffers - meminfo.cached) / 1024)));
717 output.append(AddStringRow( 724 output.append(AddStringRow(
718 "Active Anon Memory", base::IntToString(meminfo.active_anon / 1024))); 725 "Active Anon", base::IntToString(meminfo.active_anon / 1024)));
719 output.append(AddStringRow( 726 output.append(AddStringRow(
720 "Inactive Anon Memory", base::IntToString(meminfo.inactive_anon / 1024))); 727 "Inactive Anon", base::IntToString(meminfo.inactive_anon / 1024)));
721 output.append(AddStringRow( 728 output.append(AddStringRow(
722 "Shared Memory", base::IntToString(meminfo.shmem / 1024))); 729 "Shared", base::IntToString(meminfo.shmem / 1024)));
723 output.append("</table>"); 730 output.append("</table>");
724 731
725 AppendFooter(&output); 732 AppendFooter(&output);
726 return output; 733 return output;
727 } 734 }
728 735
729 #endif // OS_CHROMEOS 736 #endif // OS_CHROMEOS
730 737
731 // AboutDnsHandler bounces the request back to the IO thread to collect 738 // AboutDnsHandler bounces the request back to the IO thread to collect
732 // the DNS information. 739 // the DNS information.
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 if (host == chrome::kChromeUIChromeURLsHost) { 1406 if (host == chrome::kChromeUIChromeURLsHost) {
1400 response = ChromeURLs(); 1407 response = ChromeURLs();
1401 } else if (host == chrome::kChromeUICreditsHost) { 1408 } else if (host == chrome::kChromeUICreditsHost) {
1402 int idr = (path == kCreditsJsPath) ? IDR_CREDITS_JS : IDR_CREDITS_HTML; 1409 int idr = (path == kCreditsJsPath) ? IDR_CREDITS_JS : IDR_CREDITS_HTML;
1403 response = ResourceBundle::GetSharedInstance().GetRawDataResource( 1410 response = ResourceBundle::GetSharedInstance().GetRawDataResource(
1404 idr).as_string(); 1411 idr).as_string();
1405 #if defined(OS_CHROMEOS) 1412 #if defined(OS_CHROMEOS)
1406 } else if (host == chrome::kChromeUICryptohomeHost) { 1413 } else if (host == chrome::kChromeUICryptohomeHost) {
1407 response = AboutCryptohome(path); 1414 response = AboutCryptohome(path);
1408 } else if (host == chrome::kChromeUIDiscardsHost) { 1415 } else if (host == chrome::kChromeUIDiscardsHost) {
1409 response = AboutDiscards(); 1416 response = AboutDiscards(path);
1410 #endif 1417 #endif
1411 } else if (host == chrome::kChromeUIDNSHost) { 1418 } else if (host == chrome::kChromeUIDNSHost) {
1412 AboutDnsHandler::Start(this, request_id); 1419 AboutDnsHandler::Start(this, request_id);
1413 return; 1420 return;
1414 } else if (host == chrome::kChromeUIHistogramsHost) { 1421 } else if (host == chrome::kChromeUIHistogramsHost) {
1415 response = AboutHistograms(path); 1422 response = AboutHistograms(path);
1416 #if defined(OS_LINUX) 1423 #if defined(OS_LINUX)
1417 } else if (host == chrome::kChromeUILinuxProxyConfigHost) { 1424 } else if (host == chrome::kChromeUILinuxProxyConfigHost) {
1418 response = AboutLinuxProxyConfig(); 1425 response = AboutLinuxProxyConfig();
1419 #endif 1426 #endif
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1600 return false; 1607 return false;
1601 } 1608 }
1602 1609
1603 std::vector<std::string> ChromePaths() { 1610 std::vector<std::string> ChromePaths() {
1604 std::vector<std::string> paths; 1611 std::vector<std::string> paths;
1605 paths.reserve(arraysize(kChromePaths)); 1612 paths.reserve(arraysize(kChromePaths));
1606 for (size_t i = 0; i < arraysize(kChromePaths); i++) 1613 for (size_t i = 0; i < arraysize(kChromePaths); i++)
1607 paths.push_back(kChromePaths[i]); 1614 paths.push_back(kChromePaths[i]);
1608 return paths; 1615 return paths;
1609 } 1616 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/oom_priority_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698