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

Side by Side Diff: chrome/browser/devtools/devtools_ui_bindings.cc

Issue 377723003: Remove some unnecessary heap allocations and copies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: devtools only Created 6 years, 5 months 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
« no previous file with comments | « chrome/browser/devtools/devtools_ui_bindings.h ('k') | chrome/browser/ui/webui/inspect_ui.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/devtools/devtools_ui_bindings.h" 5 #include "chrome/browser/devtools/devtools_ui_bindings.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 LOG(ERROR) << "Invalid message was sent to embedder: " << message; 380 LOG(ERROR) << "Invalid message was sent to embedder: " << message;
381 return; 381 return;
382 } 382 }
383 383
384 int id = 0; 384 int id = 0;
385 dict->GetInteger(kFrontendHostId, &id); 385 dict->GetInteger(kFrontendHostId, &id);
386 386
387 std::string error; 387 std::string error;
388 embedder_message_dispatcher_->Dispatch(method, params, &error); 388 embedder_message_dispatcher_->Dispatch(method, params, &error);
389 if (id) { 389 if (id) {
390 scoped_ptr<base::Value> id_value(base::Value::CreateIntegerValue(id)); 390 base::FundamentalValue id_value(id);
391 scoped_ptr<base::Value> error_value(base::Value::CreateStringValue(error)); 391 base::StringValue error_value(error);
392 CallClientFunction("InspectorFrontendAPI.embedderMessageAck", 392 CallClientFunction("InspectorFrontendAPI.embedderMessageAck",
393 id_value.get(), error_value.get(), NULL); 393 &id_value, &error_value, NULL);
394 } 394 }
395 } 395 }
396 396
397 void DevToolsUIBindings::ActivateWindow() { 397 void DevToolsUIBindings::ActivateWindow() {
398 delegate_->ActivateWindow(); 398 delegate_->ActivateWindow();
399 } 399 }
400 400
401 void DevToolsUIBindings::CloseWindow() { 401 void DevToolsUIBindings::CloseWindow() {
402 delegate_->CloseWindow(); 402 delegate_->CloseWindow();
403 } 403 }
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 616
617 DCHECK(device_listener_enabled_ != enable); 617 DCHECK(device_listener_enabled_ != enable);
618 device_listener_enabled_ = enable; 618 device_listener_enabled_ = enable;
619 if (enable) 619 if (enable)
620 adb_bridge->AddDeviceCountListener(this); 620 adb_bridge->AddDeviceCountListener(this);
621 else 621 else
622 adb_bridge->RemoveDeviceCountListener(this); 622 adb_bridge->RemoveDeviceCountListener(this);
623 } 623 }
624 624
625 void DevToolsUIBindings::DeviceCountChanged(int count) { 625 void DevToolsUIBindings::DeviceCountChanged(int count) {
626 base::FundamentalValue value(count); 626 DispatchEventOnFrontend(kDeviceCountChanged, base::FundamentalValue(count));
627 DispatchEventOnFrontend(kDeviceCountChanged, &value);
628 } 627 }
629 628
630 void DevToolsUIBindings::PopulateRemoteDevices( 629 void DevToolsUIBindings::PopulateRemoteDevices(
631 const std::string& source, 630 const std::string& source,
632 scoped_ptr<base::ListValue> targets) { 631 const base::ListValue& targets) {
633 DispatchEventOnFrontend(kDevicesChanged, targets.get()); 632 DispatchEventOnFrontend(kDevicesChanged, targets);
634 } 633 }
635 634
636 void DevToolsUIBindings::FileSavedAs(const std::string& url) { 635 void DevToolsUIBindings::FileSavedAs(const std::string& url) {
637 base::StringValue url_value(url); 636 base::StringValue url_value(url);
638 CallClientFunction("InspectorFrontendAPI.savedURL", &url_value, NULL, NULL); 637 CallClientFunction("InspectorFrontendAPI.savedURL", &url_value, NULL, NULL);
639 } 638 }
640 639
641 void DevToolsUIBindings::CanceledFileSaveAs(const std::string& url) { 640 void DevToolsUIBindings::CanceledFileSaveAs(const std::string& url) {
642 base::StringValue url_value(url); 641 base::StringValue url_value(url);
643 CallClientFunction("InspectorFrontendAPI.canceledSaveURL", 642 CallClientFunction("InspectorFrontendAPI.canceledSaveURL",
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 } 788 }
790 } 789 }
791 } 790 }
792 base::string16 javascript = 791 base::string16 javascript =
793 base::UTF8ToUTF16(function_name + "(" + params + ");"); 792 base::UTF8ToUTF16(function_name + "(" + params + ");");
794 web_contents_->GetMainFrame()->ExecuteJavaScript(javascript); 793 web_contents_->GetMainFrame()->ExecuteJavaScript(javascript);
795 } 794 }
796 795
797 void DevToolsUIBindings::DispatchEventOnFrontend( 796 void DevToolsUIBindings::DispatchEventOnFrontend(
798 const std::string& event_type, 797 const std::string& event_type,
799 const base::Value* event_data) { 798 const base::Value& event_data) {
800 if (subscribers_.find(event_type) == subscribers_.end()) 799 if (subscribers_.find(event_type) == subscribers_.end())
801 return; 800 return;
802 base::StringValue event_type_value = base::StringValue(event_type); 801 base::StringValue event_type_value(event_type);
803 CallClientFunction("InspectorFrontendAPI.dispatchEventToListeners", 802 CallClientFunction("InspectorFrontendAPI.dispatchEventToListeners",
804 &event_type_value, 803 &event_type_value,
805 event_data, 804 &event_data,
806 NULL); 805 NULL);
807 } 806 }
808 807
809 void DevToolsUIBindings::DocumentOnLoadCompletedInMainFrame() { 808 void DevToolsUIBindings::DocumentOnLoadCompletedInMainFrame() {
810 // Call delegate first - it seeds importants bit of information. 809 // Call delegate first - it seeds importants bit of information.
811 delegate_->OnLoadCompleted(); 810 delegate_->OnLoadCompleted();
812 811
813 UpdateTheme(); 812 UpdateTheme();
814 AddDevToolsExtensionsToClient(); 813 AddDevToolsExtensionsToClient();
815 } 814 }
OLDNEW
« no previous file with comments | « chrome/browser/devtools/devtools_ui_bindings.h ('k') | chrome/browser/ui/webui/inspect_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698