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

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

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

Powered by Google App Engine
This is Rietveld 408576698