| OLD | NEW |
| 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/about_ui.h" | 5 #include "chrome/browser/ui/webui/about_ui.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 refresh, | 566 refresh, |
| 567 request_id)); | 567 request_id)); |
| 568 } | 568 } |
| 569 | 569 |
| 570 std::string AboutDiscardsRun() { | 570 std::string AboutDiscardsRun() { |
| 571 std::string output; | 571 std::string output; |
| 572 AppendHeader(&output, 0, "About discards"); | 572 AppendHeader(&output, 0, "About discards"); |
| 573 output.append(StringPrintf("<meta http-equiv=\"refresh\" content=\"2;%s\">", | 573 output.append(StringPrintf("<meta http-equiv=\"refresh\" content=\"2;%s\">", |
| 574 chrome::kChromeUIDiscardsURL)); | 574 chrome::kChromeUIDiscardsURL)); |
| 575 output.append(WrapWithTag("p", "Discarding a tab...")); | 575 output.append(WrapWithTag("p", "Discarding a tab...")); |
| 576 g_browser_process->oom_priority_manager()->DiscardTab(); | 576 g_browser_process->oom_priority_manager()->LogMemoryAndDiscardTab(); |
| 577 AppendFooter(&output); | 577 AppendFooter(&output); |
| 578 return output; | 578 return output; |
| 579 } | 579 } |
| 580 | 580 |
| 581 std::string AboutDiscards(const std::string& path) { | 581 std::string AboutDiscards(const std::string& path) { |
| 582 std::string output; | 582 std::string output; |
| 583 const char kRunCommand[] = "run"; | 583 const char kRunCommand[] = "run"; |
| 584 if (path == kRunCommand) | 584 if (path == kRunCommand) |
| 585 return AboutDiscardsRun(); | 585 return AboutDiscardsRun(); |
| 586 AppendHeader(&output, 0, "About discards"); | 586 AppendHeader(&output, 0, "About discards"); |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 } | 861 } |
| 862 | 862 |
| 863 void FinishMemoryDataRequest(const std::string& path, | 863 void FinishMemoryDataRequest(const std::string& path, |
| 864 AboutUIHTMLSource* source, | 864 AboutUIHTMLSource* source, |
| 865 int request_id) { | 865 int request_id) { |
| 866 if (path == kStringsJsPath) { | 866 if (path == kStringsJsPath) { |
| 867 // The AboutMemoryHandler cleans itself up, but |StartFetch()| will want | 867 // The AboutMemoryHandler cleans itself up, but |StartFetch()| will want |
| 868 // the refcount to be greater than 0. | 868 // the refcount to be greater than 0. |
| 869 scoped_refptr<AboutMemoryHandler> | 869 scoped_refptr<AboutMemoryHandler> |
| 870 handler(new AboutMemoryHandler(source, request_id)); | 870 handler(new AboutMemoryHandler(source, request_id)); |
| 871 handler->StartFetch(); | 871 // TODO(jamescook): Maybe this shouldn't update UMA? |
| 872 handler->StartFetch(MemoryDetails::UPDATE_USER_METRICS); |
| 872 } else { | 873 } else { |
| 873 source->FinishDataRequest( | 874 source->FinishDataRequest( |
| 874 ResourceBundle::GetSharedInstance().GetRawDataResource( | 875 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 875 path == kMemoryJsPath ? IDR_ABOUT_MEMORY_JS : | 876 path == kMemoryJsPath ? IDR_ABOUT_MEMORY_JS : |
| 876 IDR_ABOUT_MEMORY_HTML).as_string(), request_id); | 877 IDR_ABOUT_MEMORY_HTML).as_string(), request_id); |
| 877 } | 878 } |
| 878 } | 879 } |
| 879 | 880 |
| 880 // Handler for filling in the "about:stats" page, as called by the browser's | 881 // Handler for filling in the "about:stats" page, as called by the browser's |
| 881 // About handler processing. | 882 // About handler processing. |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1506 } | 1507 } |
| 1507 | 1508 |
| 1508 AboutUI::AboutUI(content::WebUI* web_ui, const std::string& name) | 1509 AboutUI::AboutUI(content::WebUI* web_ui, const std::string& name) |
| 1509 : WebUIController(web_ui) { | 1510 : WebUIController(web_ui) { |
| 1510 Profile* profile = Profile::FromWebUI(web_ui); | 1511 Profile* profile = Profile::FromWebUI(web_ui); |
| 1511 ChromeURLDataManager::DataSource* source = | 1512 ChromeURLDataManager::DataSource* source = |
| 1512 new AboutUIHTMLSource(name, profile); | 1513 new AboutUIHTMLSource(name, profile); |
| 1513 if (source) | 1514 if (source) |
| 1514 profile->GetChromeURLDataManager()->AddDataSource(source); | 1515 profile->GetChromeURLDataManager()->AddDataSource(source); |
| 1515 } | 1516 } |
| OLD | NEW |