| Index: chrome/browser/ui/webui/tracing_ui.cc
|
| diff --git a/chrome/browser/ui/webui/gpu_internals_ui.cc b/chrome/browser/ui/webui/tracing_ui.cc
|
| similarity index 63%
|
| copy from chrome/browser/ui/webui/gpu_internals_ui.cc
|
| copy to chrome/browser/ui/webui/tracing_ui.cc
|
| index 8088c55ffbe313b4d3e6fd75333302d6c0cd93b5..7b277c0def44d4521d7a23642ef438507ffce326 100644
|
| --- a/chrome/browser/ui/webui/gpu_internals_ui.cc
|
| +++ b/chrome/browser/ui/webui/tracing_ui.cc
|
| @@ -2,132 +2,120 @@
|
| // 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/gpu_internals_ui.h"
|
| +#include "chrome/browser/ui/webui/tracing_ui.h"
|
|
|
| -#include <algorithm>
|
| #include <string>
|
| -#include <utility>
|
| -#include <vector>
|
|
|
| #include "base/command_line.h"
|
| #include "base/file_util.h"
|
| -#include "base/memory/singleton.h"
|
| -#include "base/message_loop.h"
|
| -#include "base/path_service.h"
|
| #include "base/scoped_ptr.h"
|
| -#include "base/stringprintf.h"
|
| #include "base/string_number_conversions.h"
|
| -#include "base/string_piece.h"
|
| #include "base/utf_string_conversions.h"
|
| -#include "base/values.h"
|
| -#include "chrome/browser/browser_process.h"
|
| -#include "chrome/browser/io_thread.h"
|
| -#include "chrome/browser/net/chrome_net_log.h"
|
| -#include "chrome/browser/net/connection_tester.h"
|
| -#include "chrome/browser/net/passive_log_collector.h"
|
| -#include "chrome/browser/net/url_fixer_upper.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/ui/shell_dialogs.h"
|
| -#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
|
| #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
|
| -#include "chrome/common/chrome_paths.h"
|
| #include "chrome/common/chrome_version_info.h"
|
| -#include "chrome/common/jstemplate_builder.h"
|
| #include "chrome/common/url_constants.h"
|
| -#include "content/browser/browser_thread.h"
|
| #include "content/browser/gpu/gpu_data_manager.h"
|
| -#include "content/browser/gpu/gpu_process_host.h"
|
| #include "content/browser/renderer_host/render_view_host.h"
|
| #include "content/browser/tab_contents/tab_contents.h"
|
| #include "content/browser/tab_contents/tab_contents_view.h"
|
| #include "content/browser/trace_controller.h"
|
| #include "grit/browser_resources.h"
|
| #include "grit/generated_resources.h"
|
| -#include "net/base/escape.h"
|
| -#include "net/url_request/url_request_context_getter.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
| -#include "ui/base/resource/resource_bundle.h"
|
|
|
| namespace {
|
|
|
| -ChromeWebUIDataSource* CreateGpuHTMLSource() {
|
| +ChromeWebUIDataSource* CreateTracingHTMLSource() {
|
| ChromeWebUIDataSource* source =
|
| - new ChromeWebUIDataSource(chrome::kChromeUIGpuInternalsHost);
|
| + new ChromeWebUIDataSource(chrome::kChromeUITracingHost);
|
|
|
| source->set_json_path("strings.js");
|
| - source->add_resource_path("gpu_internals.js", IDR_GPU_INTERNALS_JS);
|
| - source->set_default_resource(IDR_GPU_INTERNALS_HTML);
|
| + source->add_resource_path("tracing.js", IDR_TRACING_JS);
|
| + source->set_default_resource(IDR_TRACING_HTML);
|
| + source->AddLocalizedString("tracingTitle", IDS_TRACING_TITLE);
|
| return source;
|
| }
|
|
|
| // This class receives javascript messages from the renderer.
|
| // Note that the WebUI infrastructure runs on the UI thread, therefore all of
|
| // this class's methods are expected to run on the UI thread.
|
| -class GpuMessageHandler
|
| +class TracingMessageHandler
|
| : public WebUIMessageHandler,
|
| public SelectFileDialog::Listener,
|
| - public base::SupportsWeakPtr<GpuMessageHandler>,
|
| + public base::SupportsWeakPtr<TracingMessageHandler>,
|
| public TraceSubscriber {
|
| public:
|
| - GpuMessageHandler();
|
| - virtual ~GpuMessageHandler();
|
| + TracingMessageHandler();
|
| + virtual ~TracingMessageHandler();
|
|
|
| // WebUIMessageHandler implementation.
|
| - virtual WebUIMessageHandler* Attach(WebUI* web_ui) OVERRIDE;
|
| - virtual void RegisterMessages() OVERRIDE;
|
| + virtual WebUIMessageHandler* Attach(WebUI* web_ui);
|
| + virtual void RegisterMessages();
|
|
|
| - // Messages
|
| - void OnBeginTracing(const ListValue* list);
|
| - void OnEndTracingAsync(const ListValue* list);
|
| + // SelectFileDialog::Listener implementation
|
| + virtual void FileSelected(const FilePath& path, int index, void* params);
|
| + virtual void FileSelectionCanceled(void* params);
|
| +
|
| + // TraceSubscriber implementation.
|
| + virtual void OnEndTracingComplete();
|
| + virtual void OnTraceDataCollected(const std::string& json_events);
|
| + virtual void OnTraceBufferPercentFullReply(float percent_full);
|
| +
|
| + // Messages.
|
| void OnBrowserBridgeInitialized(const ListValue* list);
|
| void OnCallAsync(const ListValue* list);
|
| + void OnBeginTracing(const ListValue* list);
|
| + void OnEndTracingAsync(const ListValue* list);
|
| void OnBeginRequestBufferPercentFull(const ListValue* list);
|
| void OnLoadTraceFile(const ListValue* list);
|
| void OnSaveTraceFile(const ListValue* list);
|
|
|
| - // Submessages dispatched from OnCallAsync
|
| + // Submessages dispatched from OnCallAsync.
|
| Value* OnRequestClientInfo(const ListValue* list);
|
| Value* OnRequestLogMessages(const ListValue* list);
|
|
|
| - // SelectFileDialog::Listener implementation
|
| - virtual void FileSelected(const FilePath& path,
|
| - int index,
|
| - void* params) OVERRIDE;
|
| - virtual void FileSelectionCanceled(void* params) OVERRIDE;
|
| -
|
| // Callbacks.
|
| void OnGpuInfoUpdate();
|
| +
|
| + // Callbacks.
|
| void LoadTraceFileComplete(std::string* file_contents);
|
| void SaveTraceFileComplete();
|
|
|
| - // TraceSubscriber implementation.
|
| - virtual void OnEndTracingComplete() OVERRIDE;
|
| - virtual void OnTraceDataCollected(const std::string& json_events) OVERRIDE;
|
| - virtual void OnTraceBufferPercentFullReply(float percent_full) OVERRIDE;
|
| -
|
| // Executes the javascript function |function_name| in the renderer, passing
|
| // it the argument |value|.
|
| void CallJavascriptFunction(const std::wstring& function_name,
|
| const Value* value);
|
|
|
| private:
|
| - DISALLOW_COPY_AND_ASSIGN(GpuMessageHandler);
|
| + // The file dialog to select a file for loading or saving traces.
|
| + scoped_refptr<SelectFileDialog> select_trace_file_dialog_;
|
| +
|
| + // The type of the file dialog as the same one is used for loading or saving
|
| + // traces.
|
| + SelectFileDialog::Type select_trace_file_dialog_type_;
|
| +
|
| + // The trace data that is to be written to the file on saving.
|
| + scoped_ptr<std::string> trace_data_to_save_;
|
| +
|
| + // True while tracing is active.
|
| + bool trace_enabled_;
|
|
|
| // Cache the Singleton for efficiency.
|
| GpuDataManager* gpu_data_manager_;
|
|
|
| + // Callback called when the GPU info is updated.
|
| Callback0::Type* gpu_info_update_callback_;
|
|
|
| - scoped_refptr<SelectFileDialog> select_trace_file_dialog_;
|
| - SelectFileDialog::Type select_trace_file_dialog_type_;
|
| - scoped_ptr<std::string> trace_data_to_save_;
|
| -
|
| - bool trace_enabled_;
|
| + DISALLOW_COPY_AND_ASSIGN(TracingMessageHandler);
|
| };
|
|
|
| +// A proxy passed to the Read and Write tasks used when loading or saving trace
|
| +// data.
|
| class TaskProxy : public base::RefCountedThreadSafe<TaskProxy> {
|
| public:
|
| - explicit TaskProxy(const base::WeakPtr<GpuMessageHandler>& handler)
|
| + explicit TaskProxy(const base::WeakPtr<TracingMessageHandler>& handler)
|
| : handler_(handler) {}
|
| void LoadTraceFileCompleteProxy(std::string* file_contents) {
|
| if (handler_)
|
| @@ -141,26 +129,29 @@ class TaskProxy : public base::RefCountedThreadSafe<TaskProxy> {
|
| }
|
|
|
| private:
|
| - base::WeakPtr<GpuMessageHandler> handler_;
|
| friend class base::RefCountedThreadSafe<TaskProxy>;
|
| +
|
| + // The message handler to call callbacks on.
|
| + base::WeakPtr<TracingMessageHandler> handler_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(TaskProxy);
|
| };
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| //
|
| -// GpuMessageHandler
|
| +// TracingMessageHandler
|
| //
|
| ////////////////////////////////////////////////////////////////////////////////
|
|
|
| -GpuMessageHandler::GpuMessageHandler()
|
| - : gpu_info_update_callback_(NULL),
|
| - select_trace_file_dialog_type_(SelectFileDialog::SELECT_NONE),
|
| - trace_enabled_(false) {
|
| +TracingMessageHandler::TracingMessageHandler()
|
| + : select_trace_file_dialog_type_(SelectFileDialog::SELECT_NONE),
|
| + trace_enabled_(false),
|
| + gpu_info_update_callback_(NULL) {
|
| gpu_data_manager_ = GpuDataManager::GetInstance();
|
| DCHECK(gpu_data_manager_);
|
| }
|
|
|
| -GpuMessageHandler::~GpuMessageHandler() {
|
| +TracingMessageHandler::~TracingMessageHandler() {
|
| if (gpu_info_update_callback_) {
|
| gpu_data_manager_->RemoveGpuInfoUpdateCallback(gpu_info_update_callback_);
|
| delete gpu_info_update_callback_;
|
| @@ -173,40 +164,40 @@ GpuMessageHandler::~GpuMessageHandler() {
|
| TraceController::GetInstance()->CancelSubscriber(this);
|
| }
|
|
|
| -WebUIMessageHandler* GpuMessageHandler::Attach(WebUI* web_ui) {
|
| +WebUIMessageHandler* TracingMessageHandler::Attach(WebUI* web_ui) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| WebUIMessageHandler* result = WebUIMessageHandler::Attach(web_ui);
|
| return result;
|
| }
|
|
|
| -/* BrowserBridge.callAsync prepends a requestID to these messages. */
|
| -void GpuMessageHandler::RegisterMessages() {
|
| +void TracingMessageHandler::RegisterMessages() {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| web_ui_->RegisterMessageCallback(
|
| - "beginTracing",
|
| - NewCallback(this, &GpuMessageHandler::OnBeginTracing));
|
| - web_ui_->RegisterMessageCallback(
|
| - "endTracingAsync",
|
| - NewCallback(this, &GpuMessageHandler::OnEndTracingAsync));
|
| - web_ui_->RegisterMessageCallback(
|
| "browserBridgeInitialized",
|
| - NewCallback(this, &GpuMessageHandler::OnBrowserBridgeInitialized));
|
| + NewCallback(this, &TracingMessageHandler::OnBrowserBridgeInitialized));
|
| web_ui_->RegisterMessageCallback(
|
| "callAsync",
|
| - NewCallback(this, &GpuMessageHandler::OnCallAsync));
|
| + NewCallback(this, &TracingMessageHandler::OnCallAsync));
|
| + web_ui_->RegisterMessageCallback(
|
| + "beginTracing",
|
| + NewCallback(this, &TracingMessageHandler::OnBeginTracing));
|
| + web_ui_->RegisterMessageCallback(
|
| + "endTracingAsync",
|
| + NewCallback(this, &TracingMessageHandler::OnEndTracingAsync));
|
| web_ui_->RegisterMessageCallback(
|
| "beginRequestBufferPercentFull",
|
| - NewCallback(this, &GpuMessageHandler::OnBeginRequestBufferPercentFull));
|
| + NewCallback(this,
|
| + &TracingMessageHandler::OnBeginRequestBufferPercentFull));
|
| web_ui_->RegisterMessageCallback(
|
| "loadTraceFile",
|
| - NewCallback(this, &GpuMessageHandler::OnLoadTraceFile));
|
| + NewCallback(this, &TracingMessageHandler::OnLoadTraceFile));
|
| web_ui_->RegisterMessageCallback(
|
| "saveTraceFile",
|
| - NewCallback(this, &GpuMessageHandler::OnSaveTraceFile));
|
| + NewCallback(this, &TracingMessageHandler::OnSaveTraceFile));
|
| }
|
|
|
| -void GpuMessageHandler::OnCallAsync(const ListValue* args) {
|
| +void TracingMessageHandler::OnCallAsync(const ListValue* args) {
|
| DCHECK_GE(args->GetSize(), static_cast<size_t>(2));
|
| // unpack args into requestId, submessage and submessageArgs
|
| bool ok;
|
| @@ -253,15 +244,89 @@ void GpuMessageHandler::OnCallAsync(const ListValue* args) {
|
| }
|
| }
|
|
|
| -void GpuMessageHandler::OnBeginRequestBufferPercentFull(const ListValue* list) {
|
| +void TracingMessageHandler::OnBrowserBridgeInitialized(const ListValue* args) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| +
|
| + DCHECK(!gpu_info_update_callback_);
|
| +
|
| + // Watch for changes in GPUInfo
|
| + gpu_info_update_callback_ =
|
| + NewCallback(this, &TracingMessageHandler::OnGpuInfoUpdate);
|
| + gpu_data_manager_->AddGpuInfoUpdateCallback(gpu_info_update_callback_);
|
| +
|
| + // Tell GpuDataManager it should have full GpuInfo. If the
|
| + // Gpu process has not run yet, this will trigger its launch.
|
| + gpu_data_manager_->RequestCompleteGpuInfoIfNeeded();
|
| +
|
| + // Run callback immediately in case the info is ready and no update in the
|
| + // future.
|
| + OnGpuInfoUpdate();
|
| +}
|
| +
|
| +Value* TracingMessageHandler::OnRequestClientInfo(const ListValue* list) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| +
|
| + DictionaryValue* dict = new DictionaryValue();
|
| +
|
| + chrome::VersionInfo version_info;
|
| +
|
| + if (!version_info.is_valid()) {
|
| + DLOG(ERROR) << "Unable to create chrome::VersionInfo";
|
| + } else {
|
| + // We have everything we need to send the right values.
|
| + dict->SetString("version", version_info.Version());
|
| + dict->SetString("cl", version_info.LastChange());
|
| + dict->SetString("version_mod",
|
| + chrome::VersionInfo::GetVersionStringModifier());
|
| + dict->SetString("official",
|
| + l10n_util::GetStringUTF16(
|
| + version_info.IsOfficialBuild() ?
|
| + IDS_ABOUT_VERSION_OFFICIAL :
|
| + IDS_ABOUT_VERSION_UNOFFICIAL));
|
| +
|
| + dict->SetString("command_line",
|
| + CommandLine::ForCurrentProcess()->GetCommandLineString());
|
| + }
|
| +
|
| + dict->SetString("blacklist_version",
|
| + GpuDataManager::GetInstance()->GetBlacklistVersion());
|
| +
|
| + return dict;
|
| +}
|
| +
|
| +Value* TracingMessageHandler::OnRequestLogMessages(const ListValue*) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| +
|
| + return gpu_data_manager_->log_messages().DeepCopy();
|
| +}
|
| +
|
| +void TracingMessageHandler::OnBeginRequestBufferPercentFull(
|
| + const ListValue* list) {
|
| TraceController::GetInstance()->GetTraceBufferPercentFullAsync(this);
|
| }
|
|
|
| +void TracingMessageHandler::OnGpuInfoUpdate() {
|
| + // Get GPU Info.
|
| + scoped_ptr<base::DictionaryValue> gpu_info_val(
|
| + gpu_data_manager_->GpuInfoAsDictionaryValue());
|
| +
|
| + // Add in blacklisting features
|
| + Value* feature_status = gpu_data_manager_->GetFeatureStatus();
|
| + if (feature_status)
|
| + gpu_info_val->Set("featureStatus", feature_status);
|
| +
|
| + // Send GPU Info to javascript.
|
| + web_ui_->CallJavascriptFunction("browserBridge.onGpuInfoUpdate",
|
| + *(gpu_info_val.get()));
|
| +}
|
| +
|
| +// A task used for asynchronously reading a file to a string. Calls the
|
| +// TaskProxy callback when reading is complete.
|
| class ReadTraceFileTask : public Task {
|
| public:
|
| ReadTraceFileTask(TaskProxy* proxy, const FilePath& path)
|
| - : proxy_(proxy)
|
| - , path_(path) {}
|
| + : proxy_(proxy),
|
| + path_(path) {}
|
|
|
| virtual void Run() {
|
| std::string* file_contents = new std::string();
|
| @@ -277,12 +342,15 @@ class ReadTraceFileTask : public Task {
|
| }
|
|
|
| private:
|
| + // The proxy that defines the completion callback.
|
| scoped_refptr<TaskProxy> proxy_;
|
|
|
| // Path of the file to open.
|
| const FilePath path_;
|
| };
|
|
|
| +// A task used for asynchronously writing a file from a string. Calls the
|
| +// TaskProxy callback when writing is complete.
|
| class WriteTraceFileTask : public Task {
|
| public:
|
| WriteTraceFileTask(TaskProxy* proxy,
|
| @@ -302,6 +370,7 @@ class WriteTraceFileTask : public Task {
|
| }
|
|
|
| private:
|
| + // The proxy that defines the completion callback.
|
| scoped_refptr<TaskProxy> proxy_;
|
|
|
| // Path of the file to save.
|
| @@ -311,7 +380,7 @@ class WriteTraceFileTask : public Task {
|
| scoped_ptr<std::string> contents_;
|
| };
|
|
|
| -void GpuMessageHandler::FileSelected(
|
| +void TracingMessageHandler::FileSelected(
|
| const FilePath& path, int index, void* params) {
|
| if (select_trace_file_dialog_type_ == SelectFileDialog::SELECT_OPEN_FILE)
|
| BrowserThread::PostTask(
|
| @@ -325,15 +394,18 @@ void GpuMessageHandler::FileSelected(
|
| select_trace_file_dialog_.release();
|
| }
|
|
|
| -void GpuMessageHandler::FileSelectionCanceled(void* params) {
|
| +void TracingMessageHandler::FileSelectionCanceled(void* params) {
|
| select_trace_file_dialog_.release();
|
| - if (select_trace_file_dialog_type_ == SelectFileDialog::SELECT_OPEN_FILE)
|
| - web_ui_->CallJavascriptFunction("tracingController.onLoadTraceFileCanceled");
|
| - else
|
| - web_ui_->CallJavascriptFunction("tracingController.onSaveTraceFileCanceled");
|
| + if (select_trace_file_dialog_type_ == SelectFileDialog::SELECT_OPEN_FILE) {
|
| + web_ui_->CallJavascriptFunction(
|
| + "tracingController.onLoadTraceFileCanceled");
|
| + } else {
|
| + web_ui_->CallJavascriptFunction(
|
| + "tracingController.onSaveTraceFileCanceled");
|
| + }
|
| }
|
|
|
| -void GpuMessageHandler::OnLoadTraceFile(const ListValue* list) {
|
| +void TracingMessageHandler::OnLoadTraceFile(const ListValue* list) {
|
| // Only allow a single dialog at a time.
|
| if (select_trace_file_dialog_.get())
|
| return;
|
| @@ -347,7 +419,7 @@ void GpuMessageHandler::OnLoadTraceFile(const ListValue* list) {
|
| web_ui_->tab_contents()->view()->GetTopLevelNativeWindow(), NULL);
|
| }
|
|
|
| -void GpuMessageHandler::LoadTraceFileComplete(std::string* file_contents) {
|
| +void TracingMessageHandler::LoadTraceFileComplete(std::string* file_contents) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| std::wstring javascript;
|
| javascript += L"tracingController.onLoadTraceFileComplete(";
|
| @@ -358,7 +430,7 @@ void GpuMessageHandler::LoadTraceFileComplete(std::string* file_contents) {
|
| WideToUTF16Hack(javascript));
|
| }
|
|
|
| -void GpuMessageHandler::OnSaveTraceFile(const ListValue* list) {
|
| +void TracingMessageHandler::OnSaveTraceFile(const ListValue* list) {
|
| // Only allow a single dialog at a time.
|
| if (select_trace_file_dialog_.get())
|
| return;
|
| @@ -380,170 +452,13 @@ void GpuMessageHandler::OnSaveTraceFile(const ListValue* list) {
|
| web_ui_->tab_contents()->view()->GetTopLevelNativeWindow(), NULL);
|
| }
|
|
|
| -void GpuMessageHandler::SaveTraceFileComplete() {
|
| +void TracingMessageHandler::SaveTraceFileComplete() {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| std::wstring javascript;
|
| web_ui_->CallJavascriptFunction("tracingController.onSaveTraceFileComplete");
|
| }
|
|
|
| -void GpuMessageHandler::OnBrowserBridgeInitialized(const ListValue* args) {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| -
|
| - DCHECK(!gpu_info_update_callback_);
|
| -
|
| - // Watch for changes in GPUInfo
|
| - gpu_info_update_callback_ =
|
| - NewCallback(this, &GpuMessageHandler::OnGpuInfoUpdate);
|
| - gpu_data_manager_->AddGpuInfoUpdateCallback(gpu_info_update_callback_);
|
| -
|
| - // Tell GpuDataManager it should have full GpuInfo. If the
|
| - // Gpu process has not run yet, this will trigger its launch.
|
| - gpu_data_manager_->RequestCompleteGpuInfoIfNeeded();
|
| -
|
| - // Run callback immediately in case the info is ready and no update in the
|
| - // future.
|
| - OnGpuInfoUpdate();
|
| -}
|
| -
|
| -Value* GpuMessageHandler::OnRequestClientInfo(const ListValue* list) {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| -
|
| - DictionaryValue* dict = new DictionaryValue();
|
| -
|
| - chrome::VersionInfo version_info;
|
| -
|
| - if (!version_info.is_valid()) {
|
| - DLOG(ERROR) << "Unable to create chrome::VersionInfo";
|
| - } else {
|
| - // We have everything we need to send the right values.
|
| - dict->SetString("version", version_info.Version());
|
| - dict->SetString("cl", version_info.LastChange());
|
| - dict->SetString("version_mod",
|
| - chrome::VersionInfo::GetVersionStringModifier());
|
| - dict->SetString("official",
|
| - l10n_util::GetStringUTF16(
|
| - version_info.IsOfficialBuild() ?
|
| - IDS_ABOUT_VERSION_OFFICIAL :
|
| - IDS_ABOUT_VERSION_UNOFFICIAL));
|
| -
|
| - dict->SetString("command_line",
|
| - CommandLine::ForCurrentProcess()->GetCommandLineString());
|
| - }
|
| -
|
| - dict->SetString("blacklist_version",
|
| - GpuDataManager::GetInstance()->GetBlacklistVersion());
|
| -
|
| - return dict;
|
| -}
|
| -
|
| -DictionaryValue* NewDescriptionValuePair(const std::string& desc,
|
| - const std::string& value) {
|
| - DictionaryValue* dict = new DictionaryValue();
|
| - dict->SetString("description", desc);
|
| - dict->SetString("value", value);
|
| - return dict;
|
| -}
|
| -
|
| -DictionaryValue* NewDescriptionValuePair(const std::string& desc,
|
| - Value* value) {
|
| - DictionaryValue* dict = new DictionaryValue();
|
| - dict->SetString("description", desc);
|
| - dict->Set("value", value);
|
| - return dict;
|
| -}
|
| -
|
| -#if defined(OS_WIN)
|
| -// Output DxDiagNode tree as nested array of {description,value} pairs
|
| -ListValue* DxDiagNodeToList(const DxDiagNode& node) {
|
| - ListValue* list = new ListValue();
|
| - for (std::map<std::string, std::string>::const_iterator it =
|
| - node.values.begin();
|
| - it != node.values.end();
|
| - ++it) {
|
| - list->Append(NewDescriptionValuePair(it->first, it->second));
|
| - }
|
| -
|
| - for (std::map<std::string, DxDiagNode>::const_iterator it =
|
| - node.children.begin();
|
| - it != node.children.end();
|
| - ++it) {
|
| - ListValue* sublist = DxDiagNodeToList(it->second);
|
| - list->Append(NewDescriptionValuePair(it->first, sublist));
|
| - }
|
| - return list;
|
| -}
|
| -
|
| -#endif // OS_WIN
|
| -
|
| -DictionaryValue* GpuInfoToDict(const GPUInfo& gpu_info) {
|
| - ListValue* basic_info = new ListValue();
|
| - basic_info->Append(NewDescriptionValuePair("Initialization time",
|
| - base::Int64ToString(gpu_info.initialization_time.InMilliseconds())));
|
| - basic_info->Append(NewDescriptionValuePair("Vendor Id",
|
| - base::StringPrintf("0x%04x", gpu_info.vendor_id)));
|
| - basic_info->Append(NewDescriptionValuePair("Device Id",
|
| - base::StringPrintf("0x%04x", gpu_info.device_id)));
|
| - basic_info->Append(NewDescriptionValuePair("Driver vendor",
|
| - gpu_info.driver_vendor));
|
| - basic_info->Append(NewDescriptionValuePair("Driver version",
|
| - gpu_info.driver_version));
|
| - basic_info->Append(NewDescriptionValuePair("Driver date",
|
| - gpu_info.driver_date));
|
| - basic_info->Append(NewDescriptionValuePair("Pixel shader version",
|
| - gpu_info.pixel_shader_version));
|
| - basic_info->Append(NewDescriptionValuePair("Vertex shader version",
|
| - gpu_info.vertex_shader_version));
|
| - basic_info->Append(NewDescriptionValuePair("GL version",
|
| - gpu_info.gl_version));
|
| - basic_info->Append(NewDescriptionValuePair("GL_VENDOR",
|
| - gpu_info.gl_vendor));
|
| - basic_info->Append(NewDescriptionValuePair("GL_RENDERER",
|
| - gpu_info.gl_renderer));
|
| - basic_info->Append(NewDescriptionValuePair("GL_VERSION",
|
| - gpu_info.gl_version_string));
|
| - basic_info->Append(NewDescriptionValuePair("GL_EXTENSIONS",
|
| - gpu_info.gl_extensions));
|
| -
|
| - DictionaryValue* info = new DictionaryValue();
|
| - info->Set("basic_info", basic_info);
|
| -
|
| -#if defined(OS_WIN)
|
| - Value* dx_info;
|
| - if (gpu_info.dx_diagnostics.children.size())
|
| - dx_info = DxDiagNodeToList(gpu_info.dx_diagnostics);
|
| - else
|
| - dx_info = Value::CreateNullValue();
|
| - info->Set("diagnostics", dx_info);
|
| -#endif
|
| -
|
| - return info;
|
| -}
|
| -
|
| -Value* GpuMessageHandler::OnRequestLogMessages(const ListValue*) {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| -
|
| - return gpu_data_manager_->log_messages().DeepCopy();
|
| -}
|
| -
|
| -void GpuMessageHandler::OnGpuInfoUpdate() {
|
| - const GPUInfo& gpu_info = gpu_data_manager_->gpu_info();
|
| -
|
| - // Get GPU Info.
|
| - DictionaryValue* gpu_info_val = GpuInfoToDict(gpu_info);
|
| -
|
| - // Add in blacklisting features
|
| - Value* feature_status = gpu_data_manager_->GetFeatureStatus();
|
| - if (feature_status)
|
| - gpu_info_val->Set("featureStatus", feature_status);
|
| -
|
| - // Send GPU Info to javascript.
|
| - web_ui_->CallJavascriptFunction("browserBridge.onGpuInfoUpdate",
|
| - *gpu_info_val);
|
| -
|
| - delete gpu_info_val;
|
| -}
|
| -
|
| -void GpuMessageHandler::OnBeginTracing(const ListValue* args) {
|
| +void TracingMessageHandler::OnBeginTracing(const ListValue* args) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| trace_enabled_ = true;
|
| // TODO(jbates) This may fail, but that's OK for current use cases.
|
| @@ -553,7 +468,7 @@ void GpuMessageHandler::OnBeginTracing(const ListValue* args) {
|
| TraceController::GetInstance()->BeginTracing(this);
|
| }
|
|
|
| -void GpuMessageHandler::OnEndTracingAsync(const ListValue* list) {
|
| +void TracingMessageHandler::OnEndTracingAsync(const ListValue* list) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| // TODO(nduca): fix javascript code to make sure trace_enabled_ is always true
|
| @@ -567,13 +482,14 @@ void GpuMessageHandler::OnEndTracingAsync(const ListValue* list) {
|
| }
|
| }
|
|
|
| -void GpuMessageHandler::OnEndTracingComplete() {
|
| +void TracingMessageHandler::OnEndTracingComplete() {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| trace_enabled_ = false;
|
| web_ui_->CallJavascriptFunction("tracingController.onEndTracingComplete");
|
| }
|
|
|
| -void GpuMessageHandler::OnTraceDataCollected(const std::string& json_events) {
|
| +void TracingMessageHandler::OnTraceDataCollected(
|
| + const std::string& json_events) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| std::wstring javascript;
|
| javascript += L"tracingController.onTraceDataCollected(";
|
| @@ -584,7 +500,7 @@ void GpuMessageHandler::OnTraceDataCollected(const std::string& json_events) {
|
| WideToUTF16Hack(javascript));
|
| }
|
|
|
| -void GpuMessageHandler::OnTraceBufferPercentFullReply(float percent_full) {
|
| +void TracingMessageHandler::OnTraceBufferPercentFullReply(float percent_full) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| web_ui_->CallJavascriptFunction(
|
| "tracingController.onRequestBufferPercentFullComplete",
|
| @@ -596,14 +512,14 @@ void GpuMessageHandler::OnTraceBufferPercentFullReply(float percent_full) {
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| //
|
| -// GpuInternalsUI
|
| +// TracingUI
|
| //
|
| ////////////////////////////////////////////////////////////////////////////////
|
|
|
| -GpuInternalsUI::GpuInternalsUI(TabContents* contents) : ChromeWebUI(contents) {
|
| - AddMessageHandler((new GpuMessageHandler())->Attach(this));
|
| +TracingUI::TracingUI(TabContents* contents) : ChromeWebUI(contents) {
|
| + AddMessageHandler((new TracingMessageHandler())->Attach(this));
|
|
|
| - // Set up the chrome://gpu-internals/ source.
|
| - Profile* profile = Profile::FromBrowserContext(contents->browser_context());
|
| - profile->GetChromeURLDataManager()->AddDataSource(CreateGpuHTMLSource());
|
| + // Set up the chrome://tracing/ source.
|
| + Profile::FromBrowserContext(contents->browser_context())->
|
| + GetChromeURLDataManager()->AddDataSource(CreateTracingHTMLSource());
|
| }
|
|
|