diff options
-rw-r--r-- | chrome/browser/feedback/feedback_data.cc | 6 | ||||
-rw-r--r-- | chrome/browser/feedback/feedback_data.h | 3 | ||||
-rw-r--r-- | chrome/browser/resources/feedback/html/default.html | 4 | ||||
-rw-r--r-- | chrome/browser/resources/feedback/js/feedback.js | 10 | ||||
-rw-r--r-- | chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc | 3 | ||||
-rw-r--r-- | chrome/browser/ui/webui/chromeos/slow_trace_ui.cc | 81 | ||||
-rw-r--r-- | chrome/browser/ui/webui/chromeos/slow_trace_ui.h | 58 | ||||
-rw-r--r-- | chrome/chrome_browser_ui.gypi | 2 | ||||
-rw-r--r-- | chrome/common/url_constants.cc | 1 | ||||
-rw-r--r-- | chrome/common/url_constants.h | 1 |
10 files changed, 165 insertions, 4 deletions
diff --git a/chrome/browser/feedback/feedback_data.cc b/chrome/browser/feedback/feedback_data.cc index 198ea03..7c1aff7 100644 --- a/chrome/browser/feedback/feedback_data.cc +++ b/chrome/browser/feedback/feedback_data.cc @@ -113,7 +113,7 @@ void FeedbackData::SetAndCompressSystemInfo( if (!manager || !manager->GetTraceData( trace_id_, - base::Bind(&FeedbackData::OnGetTraceData, this))) { + base::Bind(&FeedbackData::OnGetTraceData, this, trace_id_))) { trace_id_ = 0; } } @@ -134,8 +134,12 @@ void FeedbackData::SetAndCompressSystemInfo( } void FeedbackData::OnGetTraceData( + int trace_id_, scoped_refptr<base::RefCountedString> trace_data) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + TracingManager* manager = TracingManager::Get(); + if (manager) + manager->DiscardTraceData(trace_id_); scoped_ptr<std::string> data(new std::string(trace_data->data())); diff --git a/chrome/browser/feedback/feedback_data.h b/chrome/browser/feedback/feedback_data.h index f88b007..a33ae12 100644 --- a/chrome/browser/feedback/feedback_data.h +++ b/chrome/browser/feedback/feedback_data.h @@ -94,7 +94,8 @@ class FeedbackData : public base::RefCountedThreadSafe<FeedbackData> { virtual ~FeedbackData(); - void OnGetTraceData(scoped_refptr<base::RefCountedString> trace_data); + void OnGetTraceData(int trace_id, + scoped_refptr<base::RefCountedString> trace_data); Profile* profile_; diff --git a/chrome/browser/resources/feedback/html/default.html b/chrome/browser/resources/feedback/html/default.html index b1960cf..25f1f31 100644 --- a/chrome/browser/resources/feedback/html/default.html +++ b/chrome/browser/resources/feedback/html/default.html @@ -63,8 +63,8 @@ <!-- Performance Feedback --> <div id="performance-info-area" hidden> <input id="performance-info-checkbox" type="checkbox"> - <label id="performance-info-label" i18n-content="performance-trace"> - </label> + <a id="performance-info-link" href="#" i18n-content="performance-trace"> + </a> </div> </if> <!-- Privacy node --> diff --git a/chrome/browser/resources/feedback/js/feedback.js b/chrome/browser/resources/feedback/js/feedback.js index 90c7c91..db19c91 100644 --- a/chrome/browser/resources/feedback/js/feedback.js +++ b/chrome/browser/resources/feedback/js/feedback.js @@ -72,6 +72,15 @@ function openSystemInfoWindow() { } /** + * Opens a new window with chrome://slow_trace, downloading performance data. + */ +function openSlowTraceWindow() { + chrome.windows.create( + {url: 'chrome://slow_trace/tracing.zip#' + feedbackInfo.traceId}, + function(win) {}); +} + +/** * Sends the report; after the report is sent, we need to be redirected to * the landing page, but we shouldn't be able to navigate back, hence * we open the landing page in a new tab and sendReport closes this tab. @@ -235,6 +244,7 @@ function initialize() { $('performance-info-area').hidden = false; $('performance-info-checkbox').checked = true; performanceFeedbackChanged(); + $('performance-info-link').onclick = openSlowTraceWindow; } </if> diff --git a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc index bcd3c9d..d1ae4aa 100644 --- a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc +++ b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc @@ -109,6 +109,7 @@ #include "chrome/browser/ui/webui/chromeos/proxy_settings_ui.h" #include "chrome/browser/ui/webui/chromeos/salsa_ui.h" #include "chrome/browser/ui/webui/chromeos/sim_unlock_ui.h" +#include "chrome/browser/ui/webui/chromeos/slow_trace_ui.h" #include "chrome/browser/ui/webui/chromeos/slow_ui.h" #include "chrome/browser/ui/webui/chromeos/system_info_ui.h" #endif @@ -400,6 +401,8 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui, return &NewWebUI<chromeos::SimUnlockUI>; if (url.host() == chrome::kChromeUISlowHost) return &NewWebUI<chromeos::SlowUI>; + if (url.host() == chrome::kChromeUISlowTraceHost) + return &NewWebUI<chromeos::SlowTraceController>; if (url.host() == chrome::kChromeUISystemInfoHost) return &NewWebUI<chromeos::SystemInfoUI>; if (url.host() == chrome::kChromeUINetworkHost) diff --git a/chrome/browser/ui/webui/chromeos/slow_trace_ui.cc b/chrome/browser/ui/webui/chromeos/slow_trace_ui.cc new file mode 100644 index 0000000..19f568c --- /dev/null +++ b/chrome/browser/ui/webui/chromeos/slow_trace_ui.cc @@ -0,0 +1,81 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/webui/chromeos/slow_trace_ui.h" + +#include "base/bind.h" +#include "base/memory/ref_counted_memory.h" +#include "base/message_loop/message_loop.h" +#include "base/strings/string_number_conversions.h" +#include "chrome/browser/feedback/tracing_manager.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/common/url_constants.h" +#include "content/public/browser/url_data_source.h" +#include "content/public/browser/web_ui.h" +#include "grit/theme_resources.h" +#include "ui/base/resource/resource_bundle.h" + +namespace chromeos { + +//////////////////////////////////////////////////////////////////////////////// +// +// SlowTraceSource +// +//////////////////////////////////////////////////////////////////////////////// + +SlowTraceSource::SlowTraceSource() { +} + +std::string SlowTraceSource::GetSource() const { + return chrome::kChromeUISlowTraceHost; +} + +void SlowTraceSource::StartDataRequest( + const std::string& path, + int render_process_id, + int render_view_id, + const content::URLDataSource::GotDataCallback& callback) { + int trace_id = 0; + size_t pos = path.find('#'); + TracingManager* manager = TracingManager::Get(); + if (!manager || + pos == std::string::npos || + !base::StringToInt(path.substr(pos + 1), &trace_id)) { + callback.Run(NULL); + return; + } + manager->GetTraceData(trace_id, + base::Bind(&SlowTraceSource::OnGetTraceData, + base::Unretained(this), + callback)); +} + +std::string SlowTraceSource::GetMimeType(const std::string& path) const { + return "application/zip"; +} + +SlowTraceSource::~SlowTraceSource() {} + +void SlowTraceSource::OnGetTraceData( + const content::URLDataSource::GotDataCallback& callback, + scoped_refptr<base::RefCountedString> trace_data) { + callback.Run(trace_data); +} + +//////////////////////////////////////////////////////////////////////////////// +// +// SlowTraceController +// +//////////////////////////////////////////////////////////////////////////////// + +SlowTraceController::SlowTraceController(content::WebUI* web_ui) + : WebUIController(web_ui) { + SlowTraceSource* html_source = new SlowTraceSource(); + + // Set up the chrome://slow_trace/ source. + Profile* profile = Profile::FromWebUI(web_ui); + content::URLDataSource::Add(profile, html_source); +} + +} // namespace chromeos diff --git a/chrome/browser/ui/webui/chromeos/slow_trace_ui.h b/chrome/browser/ui/webui/chromeos/slow_trace_ui.h new file mode 100644 index 0000000..82f192f --- /dev/null +++ b/chrome/browser/ui/webui/chromeos/slow_trace_ui.h @@ -0,0 +1,58 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_SLOW_TRACE_UI_H_ +#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_SLOW_TRACE_UI_H_ + +#include <string> + +#include "base/compiler_specific.h" +#include "content/public/browser/url_data_source.h" +#include "content/public/browser/web_ui_controller.h" +#include "ui/base/layout.h" + +namespace base { +class RefCountedMemory; +class RefCountedString; +} + +namespace chromeos { + +// This class provides the source for chrome://slow_trace/. It needs to be a +// separate handler that chrome://slow, because URLDataSource and +// WebUIDataSource are not descended from each other, and WebUIDataSource +// doesn't allow the MimeType to be dynamically specified. +class SlowTraceSource : public content::URLDataSource { + public: + SlowTraceSource(); + + // content::URLDataSource implementation. + virtual std::string GetSource() const OVERRIDE; + virtual void StartDataRequest( + const std::string& path, + int render_process_id, + int render_view_id, + const content::URLDataSource::GotDataCallback& callback) OVERRIDE; + virtual std::string GetMimeType(const std::string& path) const OVERRIDE; + + private: + virtual ~SlowTraceSource(); + + void OnGetTraceData(const content::URLDataSource::GotDataCallback& callback, + scoped_refptr<base::RefCountedString> trace_data); + + DISALLOW_COPY_AND_ASSIGN(SlowTraceSource); +}; + +class SlowTraceController : public content::WebUIController { + public: + explicit SlowTraceController(content::WebUI* web_ui); + + private: + DISALLOW_COPY_AND_ASSIGN(SlowTraceController); +}; + +} // namespace chromeos + +#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_SLOW_TRACE_UI_H_ diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi index 8fc36a2..7a586e2 100644 --- a/chrome/chrome_browser_ui.gypi +++ b/chrome/chrome_browser_ui.gypi @@ -2150,6 +2150,8 @@ 'browser/ui/webui/chromeos/proxy_settings_ui.h', 'browser/ui/webui/chromeos/sim_unlock_ui.cc', 'browser/ui/webui/chromeos/sim_unlock_ui.h', + 'browser/ui/webui/chromeos/slow_trace_ui.cc', + 'browser/ui/webui/chromeos/slow_trace_ui.h', 'browser/ui/webui/chromeos/slow_ui.cc', 'browser/ui/webui/chromeos/slow_ui.h', 'browser/ui/webui/chromeos/system_info_ui.cc', diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc index 8f652ce..c7ccd2b 100644 --- a/chrome/common/url_constants.cc +++ b/chrome/common/url_constants.cc @@ -270,6 +270,7 @@ const char kChromeUIRotateHost[] = "rotate"; const char kChromeUISimUnlockHost[] = "sim-unlock"; const char kChromeUISlideshowHost[] = "slideshow"; const char kChromeUISlowHost[] = "slow"; +const char kChromeUISlowTraceHost[] = "slow_trace"; const char kChromeUISystemInfoHost[] = "system"; const char kChromeUIUserImageHost[] = "userimage"; diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h index 1a85599..bd6f0e8 100644 --- a/chrome/common/url_constants.h +++ b/chrome/common/url_constants.h @@ -262,6 +262,7 @@ extern const char kChromeUIRotateHost[]; extern const char kChromeUISimUnlockHost[]; extern const char kChromeUISlideshowHost[]; extern const char kChromeUISlowHost[]; +extern const char kChromeUISlowTraceHost[]; extern const char kChromeUISystemInfoHost[]; extern const char kChromeUIUserImageHost[]; |