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

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

Issue 2666093002: Remove base::FundamentalValue (Closed)
Patch Set: Rebase Created 3 years, 9 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 int ResponseWriter::Write(net::IOBuffer* buffer, 282 int ResponseWriter::Write(net::IOBuffer* buffer,
283 int num_bytes, 283 int num_bytes,
284 const net::CompletionCallback& callback) { 284 const net::CompletionCallback& callback) {
285 std::string chunk = std::string(buffer->data(), num_bytes); 285 std::string chunk = std::string(buffer->data(), num_bytes);
286 bool encoded = false; 286 bool encoded = false;
287 if (!base::IsStringUTF8(chunk)) { 287 if (!base::IsStringUTF8(chunk)) {
288 encoded = true; 288 encoded = true;
289 base::Base64Encode(chunk, &chunk); 289 base::Base64Encode(chunk, &chunk);
290 } 290 }
291 291
292 base::FundamentalValue* id = new base::FundamentalValue(stream_id_); 292 base::Value* id = new base::Value(stream_id_);
293 base::StringValue* chunkValue = new base::StringValue(chunk); 293 base::StringValue* chunkValue = new base::StringValue(chunk);
294 base::FundamentalValue* encodedValue = new base::FundamentalValue(encoded); 294 base::Value* encodedValue = new base::Value(encoded);
295 295
296 content::BrowserThread::PostTask( 296 content::BrowserThread::PostTask(
297 content::BrowserThread::UI, FROM_HERE, 297 content::BrowserThread::UI, FROM_HERE,
298 base::Bind(&DevToolsUIBindings::CallClientFunction, bindings_, 298 base::Bind(&DevToolsUIBindings::CallClientFunction, bindings_,
299 "DevToolsAPI.streamWrite", base::Owned(id), 299 "DevToolsAPI.streamWrite", base::Owned(id),
300 base::Owned(chunkValue), base::Owned(encodedValue))); 300 base::Owned(chunkValue), base::Owned(encodedValue)));
301 return num_bytes; 301 return num_bytes;
302 } 302 }
303 303
304 int ResponseWriter::Finish(int net_error, 304 int ResponseWriter::Finish(int net_error,
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 624
625 if (message.length() < kMaxMessageChunkSize) { 625 if (message.length() < kMaxMessageChunkSize) {
626 std::string param; 626 std::string param;
627 base::EscapeJSONString(message, true, &param); 627 base::EscapeJSONString(message, true, &param);
628 base::string16 javascript = 628 base::string16 javascript =
629 base::UTF8ToUTF16("DevToolsAPI.dispatchMessage(" + param + ");"); 629 base::UTF8ToUTF16("DevToolsAPI.dispatchMessage(" + param + ");");
630 web_contents_->GetMainFrame()->ExecuteJavaScript(javascript); 630 web_contents_->GetMainFrame()->ExecuteJavaScript(javascript);
631 return; 631 return;
632 } 632 }
633 633
634 base::FundamentalValue total_size(static_cast<int>(message.length())); 634 base::Value total_size(static_cast<int>(message.length()));
635 for (size_t pos = 0; pos < message.length(); pos += kMaxMessageChunkSize) { 635 for (size_t pos = 0; pos < message.length(); pos += kMaxMessageChunkSize) {
636 base::StringValue message_value(message.substr(pos, kMaxMessageChunkSize)); 636 base::StringValue message_value(message.substr(pos, kMaxMessageChunkSize));
637 CallClientFunction("DevToolsAPI.dispatchMessageChunk", 637 CallClientFunction("DevToolsAPI.dispatchMessageChunk",
638 &message_value, pos ? NULL : &total_size, NULL); 638 &message_value, pos ? NULL : &total_size, NULL);
639 } 639 }
640 } 640 }
641 641
642 void DevToolsUIBindings::AgentHostClosed( 642 void DevToolsUIBindings::AgentHostClosed(
643 content::DevToolsAgentHost* agent_host, 643 content::DevToolsAgentHost* agent_host,
644 bool replaced_with_another_client) { 644 bool replaced_with_another_client) {
645 DCHECK(agent_host == agent_host_.get()); 645 DCHECK(agent_host == agent_host_.get());
646 agent_host_ = NULL; 646 agent_host_ = NULL;
647 delegate_->InspectedContentsClosing(); 647 delegate_->InspectedContentsClosing();
648 } 648 }
649 649
650 void DevToolsUIBindings::SendMessageAck(int request_id, 650 void DevToolsUIBindings::SendMessageAck(int request_id,
651 const base::Value* arg) { 651 const base::Value* arg) {
652 base::FundamentalValue id_value(request_id); 652 base::Value id_value(request_id);
653 CallClientFunction("DevToolsAPI.embedderMessageAck", 653 CallClientFunction("DevToolsAPI.embedderMessageAck",
654 &id_value, arg, nullptr); 654 &id_value, arg, nullptr);
655 } 655 }
656 656
657 // DevToolsEmbedderMessageDispatcher::Delegate implementation ----------------- 657 // DevToolsEmbedderMessageDispatcher::Delegate implementation -----------------
658 658
659 void DevToolsUIBindings::ActivateWindow() { 659 void DevToolsUIBindings::ActivateWindow() {
660 delegate_->ActivateWindow(); 660 delegate_->ActivateWindow();
661 } 661 }
662 662
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 std::string value; 1110 std::string value;
1111 while (rh && rh->EnumerateHeaderLines(&iterator, &name, &value)) 1111 while (rh && rh->EnumerateHeaderLines(&iterator, &name, &value))
1112 headers->SetString(name, value); 1112 headers->SetString(name, value);
1113 1113
1114 it->second.Run(&response); 1114 it->second.Run(&response);
1115 pending_requests_.erase(it); 1115 pending_requests_.erase(it);
1116 delete source; 1116 delete source;
1117 } 1117 }
1118 1118
1119 void DevToolsUIBindings::DeviceCountChanged(int count) { 1119 void DevToolsUIBindings::DeviceCountChanged(int count) {
1120 base::FundamentalValue value(count); 1120 base::Value value(count);
1121 CallClientFunction("DevToolsAPI.deviceCountUpdated", &value, NULL, 1121 CallClientFunction("DevToolsAPI.deviceCountUpdated", &value, NULL,
1122 NULL); 1122 NULL);
1123 } 1123 }
1124 1124
1125 void DevToolsUIBindings::DevicesUpdated( 1125 void DevToolsUIBindings::DevicesUpdated(
1126 const std::string& source, 1126 const std::string& source,
1127 const base::ListValue& targets) { 1127 const base::ListValue& targets) {
1128 CallClientFunction("DevToolsAPI.devicesUpdated", &targets, NULL, 1128 CallClientFunction("DevToolsAPI.devicesUpdated", &targets, NULL,
1129 NULL); 1129 NULL);
1130 } 1130 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 1172
1173 CallClientFunction("DevToolsAPI.fileSystemFilesChangedAddedRemoved", &changed, 1173 CallClientFunction("DevToolsAPI.fileSystemFilesChangedAddedRemoved", &changed,
1174 &added, &removed); 1174 &added, &removed);
1175 } 1175 }
1176 1176
1177 void DevToolsUIBindings::IndexingTotalWorkCalculated( 1177 void DevToolsUIBindings::IndexingTotalWorkCalculated(
1178 int request_id, 1178 int request_id,
1179 const std::string& file_system_path, 1179 const std::string& file_system_path,
1180 int total_work) { 1180 int total_work) {
1181 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1181 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1182 base::FundamentalValue request_id_value(request_id); 1182 base::Value request_id_value(request_id);
1183 base::StringValue file_system_path_value(file_system_path); 1183 base::StringValue file_system_path_value(file_system_path);
1184 base::FundamentalValue total_work_value(total_work); 1184 base::Value total_work_value(total_work);
1185 CallClientFunction("DevToolsAPI.indexingTotalWorkCalculated", 1185 CallClientFunction("DevToolsAPI.indexingTotalWorkCalculated",
1186 &request_id_value, &file_system_path_value, 1186 &request_id_value, &file_system_path_value,
1187 &total_work_value); 1187 &total_work_value);
1188 } 1188 }
1189 1189
1190 void DevToolsUIBindings::IndexingWorked(int request_id, 1190 void DevToolsUIBindings::IndexingWorked(int request_id,
1191 const std::string& file_system_path, 1191 const std::string& file_system_path,
1192 int worked) { 1192 int worked) {
1193 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1193 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1194 base::FundamentalValue request_id_value(request_id); 1194 base::Value request_id_value(request_id);
1195 base::StringValue file_system_path_value(file_system_path); 1195 base::StringValue file_system_path_value(file_system_path);
1196 base::FundamentalValue worked_value(worked); 1196 base::Value worked_value(worked);
1197 CallClientFunction("DevToolsAPI.indexingWorked", &request_id_value, 1197 CallClientFunction("DevToolsAPI.indexingWorked", &request_id_value,
1198 &file_system_path_value, &worked_value); 1198 &file_system_path_value, &worked_value);
1199 } 1199 }
1200 1200
1201 void DevToolsUIBindings::IndexingDone(int request_id, 1201 void DevToolsUIBindings::IndexingDone(int request_id,
1202 const std::string& file_system_path) { 1202 const std::string& file_system_path) {
1203 indexing_jobs_.erase(request_id); 1203 indexing_jobs_.erase(request_id);
1204 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1204 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1205 base::FundamentalValue request_id_value(request_id); 1205 base::Value request_id_value(request_id);
1206 base::StringValue file_system_path_value(file_system_path); 1206 base::StringValue file_system_path_value(file_system_path);
1207 CallClientFunction("DevToolsAPI.indexingDone", &request_id_value, 1207 CallClientFunction("DevToolsAPI.indexingDone", &request_id_value,
1208 &file_system_path_value, NULL); 1208 &file_system_path_value, NULL);
1209 } 1209 }
1210 1210
1211 void DevToolsUIBindings::SearchCompleted( 1211 void DevToolsUIBindings::SearchCompleted(
1212 int request_id, 1212 int request_id,
1213 const std::string& file_system_path, 1213 const std::string& file_system_path,
1214 const std::vector<std::string>& file_paths) { 1214 const std::vector<std::string>& file_paths) {
1215 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1215 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1216 base::ListValue file_paths_value; 1216 base::ListValue file_paths_value;
1217 for (std::vector<std::string>::const_iterator it(file_paths.begin()); 1217 for (std::vector<std::string>::const_iterator it(file_paths.begin());
1218 it != file_paths.end(); ++it) { 1218 it != file_paths.end(); ++it) {
1219 file_paths_value.AppendString(*it); 1219 file_paths_value.AppendString(*it);
1220 } 1220 }
1221 base::FundamentalValue request_id_value(request_id); 1221 base::Value request_id_value(request_id);
1222 base::StringValue file_system_path_value(file_system_path); 1222 base::StringValue file_system_path_value(file_system_path);
1223 CallClientFunction("DevToolsAPI.searchCompleted", &request_id_value, 1223 CallClientFunction("DevToolsAPI.searchCompleted", &request_id_value,
1224 &file_system_path_value, &file_paths_value); 1224 &file_system_path_value, &file_paths_value);
1225 } 1225 }
1226 1226
1227 void DevToolsUIBindings::ShowDevToolsConfirmInfoBar( 1227 void DevToolsUIBindings::ShowDevToolsConfirmInfoBar(
1228 const base::string16& message, 1228 const base::string16& message,
1229 const InfoBarCallback& callback) { 1229 const InfoBarCallback& callback) {
1230 if (!delegate_->GetInfoBarService()) { 1230 if (!delegate_->GetInfoBarService()) {
1231 callback.Run(false); 1231 callback.Run(false);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 web_contents_->GetMainFrame()->GetProcess()->GetID(), 1270 web_contents_->GetMainFrame()->GetProcess()->GetID(),
1271 url::Origin(extension->url())); 1271 url::Origin(extension->url()));
1272 1272
1273 std::unique_ptr<base::DictionaryValue> extension_info( 1273 std::unique_ptr<base::DictionaryValue> extension_info(
1274 new base::DictionaryValue()); 1274 new base::DictionaryValue());
1275 extension_info->Set( 1275 extension_info->Set(
1276 "startPage", 1276 "startPage",
1277 new base::StringValue(extensions::chrome_manifest_urls::GetDevToolsPage( 1277 new base::StringValue(extensions::chrome_manifest_urls::GetDevToolsPage(
1278 extension.get()).spec())); 1278 extension.get()).spec()));
1279 extension_info->Set("name", new base::StringValue(extension->name())); 1279 extension_info->Set("name", new base::StringValue(extension->name()));
1280 extension_info->Set("exposeExperimentalAPIs", 1280 extension_info->Set(
1281 new base::FundamentalValue( 1281 "exposeExperimentalAPIs",
1282 extension->permissions_data()->HasAPIPermission( 1282 new base::Value(extension->permissions_data()->HasAPIPermission(
1283 extensions::APIPermission::kExperimental))); 1283 extensions::APIPermission::kExperimental)));
1284 results.Append(std::move(extension_info)); 1284 results.Append(std::move(extension_info));
1285 } 1285 }
1286 1286
1287 CallClientFunction("DevToolsAPI.addExtensions", 1287 CallClientFunction("DevToolsAPI.addExtensions",
1288 &results, NULL, NULL); 1288 &results, NULL, NULL);
1289 } 1289 }
1290 1290
1291 void DevToolsUIBindings::SetDelegate(Delegate* delegate) { 1291 void DevToolsUIBindings::SetDelegate(Delegate* delegate) {
1292 delegate_.reset(delegate); 1292 delegate_.reset(delegate);
1293 } 1293 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 void DevToolsUIBindings::FrontendLoaded() { 1369 void DevToolsUIBindings::FrontendLoaded() {
1370 if (frontend_loaded_) 1370 if (frontend_loaded_)
1371 return; 1371 return;
1372 frontend_loaded_ = true; 1372 frontend_loaded_ = true;
1373 1373
1374 // Call delegate first - it seeds importants bit of information. 1374 // Call delegate first - it seeds importants bit of information.
1375 delegate_->OnLoadCompleted(); 1375 delegate_->OnLoadCompleted();
1376 1376
1377 AddDevToolsExtensionsToClient(); 1377 AddDevToolsExtensionsToClient();
1378 } 1378 }
OLDNEW
« no previous file with comments | « chrome/browser/custom_handlers/protocol_handler_registry.cc ('k') | chrome/browser/devtools/devtools_window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698