| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 |
| 11 #include "app/l10n_util.h" | 11 #include "app/l10n_util.h" |
| 12 #include "app/resource_bundle.h" | 12 #include "app/resource_bundle.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/i18n/number_formatting.h" | 15 #include "base/i18n/number_formatting.h" |
| 16 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 17 #include "base/metrics/stats_table.h" | 17 #include "base/metrics/stats_table.h" |
| 18 #include "base/path_service.h" | 18 #include "base/path_service.h" |
| 19 #include "base/platform_thread.h" | 19 #include "base/platform_thread.h" |
| 20 #include "base/singleton.h" |
| 20 #include "base/stringprintf.h" | 21 #include "base/stringprintf.h" |
| 21 #include "base/string_number_conversions.h" | 22 #include "base/string_number_conversions.h" |
| 22 #include "base/string_piece.h" | 23 #include "base/string_piece.h" |
| 23 #include "base/string_util.h" | 24 #include "base/string_util.h" |
| 24 #include "base/thread.h" | 25 #include "base/thread.h" |
| 25 #include "base/tracked_objects.h" | 26 #include "base/tracked_objects.h" |
| 26 #include "base/utf_string_conversions.h" | 27 #include "base/utf_string_conversions.h" |
| 27 #include "chrome/browser/about_flags.h" | 28 #include "chrome/browser/about_flags.h" |
| 28 #include "chrome/browser/browser_process.h" | 29 #include "chrome/browser/browser_process.h" |
| 29 #include "chrome/browser/browser_thread.h" | 30 #include "chrome/browser/browser_thread.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 #if defined(USE_TCMALLOC) | 82 #if defined(USE_TCMALLOC) |
| 82 #include "third_party/tcmalloc/chromium/src/google/malloc_extension.h" | 83 #include "third_party/tcmalloc/chromium/src/google/malloc_extension.h" |
| 83 #endif | 84 #endif |
| 84 | 85 |
| 85 using sync_api::SyncManager; | 86 using sync_api::SyncManager; |
| 86 | 87 |
| 87 using base::Time; | 88 using base::Time; |
| 88 using base::TimeDelta; | 89 using base::TimeDelta; |
| 89 | 90 |
| 90 #if defined(USE_TCMALLOC) | 91 #if defined(USE_TCMALLOC) |
| 92 // static |
| 93 AboutTcmallocOutputs* AboutTcmallocOutputs::GetInstance() { |
| 94 return Singleton<AboutTcmallocOutputs>::get(); |
| 95 } |
| 96 |
| 91 // Glue between the callback task and the method in the singleton. | 97 // Glue between the callback task and the method in the singleton. |
| 92 void AboutTcmallocRendererCallback(base::ProcessId pid, std::string output) { | 98 void AboutTcmallocRendererCallback(base::ProcessId pid, std::string output) { |
| 93 Singleton<AboutTcmallocOutputs>::get()->RendererCallback(pid, output); | 99 AboutTcmallocOutputs::GetInstance()->RendererCallback(pid, output); |
| 94 } | 100 } |
| 95 #endif | 101 #endif |
| 96 | 102 |
| 97 namespace { | 103 namespace { |
| 98 | 104 |
| 99 // The (alphabetized) paths used for the about pages. | 105 // The (alphabetized) paths used for the about pages. |
| 100 // Note: Keep these in sync with url_constants.h | 106 // Note: Keep these in sync with url_constants.h |
| 101 const char kAppCacheInternalsPath[] = "appcache-internals"; | 107 const char kAppCacheInternalsPath[] = "appcache-internals"; |
| 102 const char kBlobInternalsPath[] = "blob-internals"; | 108 const char kBlobInternalsPath[] = "blob-internals"; |
| 103 const char kCreditsPath[] = "credits"; | 109 const char kCreditsPath[] = "credits"; |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 // ID identifying the request. | 363 // ID identifying the request. |
| 358 int request_id_; | 364 int request_id_; |
| 359 | 365 |
| 360 DISALLOW_COPY_AND_ASSIGN(AboutDnsHandler); | 366 DISALLOW_COPY_AND_ASSIGN(AboutDnsHandler); |
| 361 }; | 367 }; |
| 362 | 368 |
| 363 #if defined(USE_TCMALLOC) | 369 #if defined(USE_TCMALLOC) |
| 364 std::string AboutTcmalloc(const std::string& query) { | 370 std::string AboutTcmalloc(const std::string& query) { |
| 365 std::string data; | 371 std::string data; |
| 366 AboutTcmallocOutputsType* outputs = | 372 AboutTcmallocOutputsType* outputs = |
| 367 Singleton<AboutTcmallocOutputs>::get()->outputs(); | 373 AboutTcmallocOutputs::GetInstance()->outputs(); |
| 368 | 374 |
| 369 // Display any stats for which we sent off requests the last time. | 375 // Display any stats for which we sent off requests the last time. |
| 370 data.append("<html><head><title>About tcmalloc</title></head><body>\n"); | 376 data.append("<html><head><title>About tcmalloc</title></head><body>\n"); |
| 371 data.append("<p>Stats as of last page load;"); | 377 data.append("<p>Stats as of last page load;"); |
| 372 data.append("reload to get stats as of this page load.</p>\n"); | 378 data.append("reload to get stats as of this page load.</p>\n"); |
| 373 data.append("<table width=\"100%\">\n"); | 379 data.append("<table width=\"100%\">\n"); |
| 374 for (AboutTcmallocOutputsType::const_iterator oit = outputs->begin(); | 380 for (AboutTcmallocOutputsType::const_iterator oit = outputs->begin(); |
| 375 oit != outputs->end(); | 381 oit != outputs->end(); |
| 376 oit++) { | 382 oit++) { |
| 377 data.append("<tr><td bgcolor=\"yellow\">"); | 383 data.append("<tr><td bgcolor=\"yellow\">"); |
| 378 data.append(oit->first); | 384 data.append(oit->first); |
| 379 data.append("</td></tr>\n"); | 385 data.append("</td></tr>\n"); |
| 380 data.append("<tr><td><pre>\n"); | 386 data.append("<tr><td><pre>\n"); |
| 381 data.append(oit->second); | 387 data.append(oit->second); |
| 382 data.append("</pre></td></tr>\n"); | 388 data.append("</pre></td></tr>\n"); |
| 383 } | 389 } |
| 384 data.append("</table>\n"); | 390 data.append("</table>\n"); |
| 385 data.append("</body></html>\n"); | 391 data.append("</body></html>\n"); |
| 386 | 392 |
| 387 // Reset our collector singleton. | 393 // Reset our collector singleton. |
| 388 outputs->clear(); | 394 outputs->clear(); |
| 389 | 395 |
| 390 // Populate the collector with stats from the local browser process | 396 // Populate the collector with stats from the local browser process |
| 391 // and send off requests to all the renderer processes. | 397 // and send off requests to all the renderer processes. |
| 392 char buffer[1024 * 32]; | 398 char buffer[1024 * 32]; |
| 393 MallocExtension::instance()->GetStats(buffer, sizeof(buffer)); | 399 MallocExtension::instance()->GetStats(buffer, sizeof(buffer)); |
| 394 std::string browser("Browser"); | 400 std::string browser("Browser"); |
| 395 Singleton<AboutTcmallocOutputs>::get()->SetOutput(browser, buffer); | 401 AboutTcmallocOutputs::GetInstance()->SetOutput(browser, buffer); |
| 396 RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator()); | 402 RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator()); |
| 397 while (!it.IsAtEnd()) { | 403 while (!it.IsAtEnd()) { |
| 398 it.GetCurrentValue()->Send(new ViewMsg_GetRendererTcmalloc); | 404 it.GetCurrentValue()->Send(new ViewMsg_GetRendererTcmalloc); |
| 399 it.Advance(); | 405 it.Advance(); |
| 400 } | 406 } |
| 401 | 407 |
| 402 return data; | 408 return data; |
| 403 } | 409 } |
| 404 #endif | 410 #endif |
| 405 | 411 |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 std::string data; | 589 std::string data; |
| 584 data.append("<!DOCTYPE HTML>\n"); | 590 data.append("<!DOCTYPE HTML>\n"); |
| 585 data.append("<html><head><meta charset=\"utf-8\"><title>"); | 591 data.append("<html><head><meta charset=\"utf-8\"><title>"); |
| 586 data.append(l10n_util::GetStringUTF8(IDS_ABOUT_SANDBOX_TITLE)); | 592 data.append(l10n_util::GetStringUTF8(IDS_ABOUT_SANDBOX_TITLE)); |
| 587 data.append("</title>"); | 593 data.append("</title>"); |
| 588 data.append("</head><body>\n"); | 594 data.append("</head><body>\n"); |
| 589 data.append("<h1>"); | 595 data.append("<h1>"); |
| 590 data.append(l10n_util::GetStringUTF8(IDS_ABOUT_SANDBOX_TITLE)); | 596 data.append(l10n_util::GetStringUTF8(IDS_ABOUT_SANDBOX_TITLE)); |
| 591 data.append("</h1>"); | 597 data.append("</h1>"); |
| 592 | 598 |
| 593 const int status = Singleton<ZygoteHost>()->sandbox_status(); | 599 const int status = ZygoteHost::GetInstance()->sandbox_status(); |
| 594 | 600 |
| 595 data.append("<table>"); | 601 data.append("<table>"); |
| 596 | 602 |
| 597 AboutSandboxRow(&data, "", IDS_ABOUT_SANDBOX_SUID_SANDBOX, | 603 AboutSandboxRow(&data, "", IDS_ABOUT_SANDBOX_SUID_SANDBOX, |
| 598 status & ZygoteHost::kSandboxSUID); | 604 status & ZygoteHost::kSandboxSUID); |
| 599 if (status & ZygoteHost::kSandboxPIDNS) { | 605 if (status & ZygoteHost::kSandboxPIDNS) { |
| 600 AboutSandboxRow(&data, " ", IDS_ABOUT_SANDBOX_PID_NAMESPACES, | 606 AboutSandboxRow(&data, " ", IDS_ABOUT_SANDBOX_PID_NAMESPACES, |
| 601 status & ZygoteHost::kSandboxPIDNS); | 607 status & ZygoteHost::kSandboxPIDNS); |
| 602 AboutSandboxRow(&data, " ", IDS_ABOUT_SANDBOX_NET_NAMESPACES, | 608 AboutSandboxRow(&data, " ", IDS_ABOUT_SANDBOX_NET_NAMESPACES, |
| 603 status & ZygoteHost::kSandboxNetNS); | 609 status & ZygoteHost::kSandboxNetNS); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 AboutSource::AboutSource() | 830 AboutSource::AboutSource() |
| 825 : DataSource(chrome::kAboutScheme, MessageLoop::current()) { | 831 : DataSource(chrome::kAboutScheme, MessageLoop::current()) { |
| 826 // This should be a singleton. | 832 // This should be a singleton. |
| 827 DCHECK(!about_source); | 833 DCHECK(!about_source); |
| 828 about_source = this; | 834 about_source = this; |
| 829 | 835 |
| 830 // Add us to the global URL handler on the IO thread. | 836 // Add us to the global URL handler on the IO thread. |
| 831 BrowserThread::PostTask( | 837 BrowserThread::PostTask( |
| 832 BrowserThread::IO, FROM_HERE, | 838 BrowserThread::IO, FROM_HERE, |
| 833 NewRunnableMethod( | 839 NewRunnableMethod( |
| 834 Singleton<ChromeURLDataManager>::get(), | 840 ChromeURLDataManager::GetInstance(), |
| 835 &ChromeURLDataManager::AddDataSource, | 841 &ChromeURLDataManager::AddDataSource, |
| 836 make_scoped_refptr(this))); | 842 make_scoped_refptr(this))); |
| 837 } | 843 } |
| 838 | 844 |
| 839 AboutSource::~AboutSource() { | 845 AboutSource::~AboutSource() { |
| 840 about_source = NULL; | 846 about_source = NULL; |
| 841 } | 847 } |
| 842 | 848 |
| 843 void AboutSource::StartDataRequest(const std::string& path_raw, | 849 void AboutSource::StartDataRequest(const std::string& path_raw, |
| 844 bool is_off_the_record, int request_id) { | 850 bool is_off_the_record, int request_id) { |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1209 // Run the dialog. This will re-use the existing one if it's already up. | 1215 // Run the dialog. This will re-use the existing one if it's already up. |
| 1210 AboutIPCDialog::RunDialog(); | 1216 AboutIPCDialog::RunDialog(); |
| 1211 return true; | 1217 return true; |
| 1212 } | 1218 } |
| 1213 #endif | 1219 #endif |
| 1214 | 1220 |
| 1215 #endif // OFFICIAL_BUILD | 1221 #endif // OFFICIAL_BUILD |
| 1216 | 1222 |
| 1217 return false; | 1223 return false; |
| 1218 } | 1224 } |
| OLD | NEW |