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

Side by Side Diff: chrome/browser/automation/testing_automation_provider.cc

Issue 10035042: Rewrite base::JSONReader to be 35-40% faster, depending on the input string. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments/fix Win Created 8 years, 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/automation/testing_automation_provider.h" 5 #include "chrome/browser/automation/testing_automation_provider.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 2110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2121 BlockedContentTabHelper* blocked_content = 2121 BlockedContentTabHelper* blocked_content =
2122 tab_contents->blocked_content_tab_helper(); 2122 tab_contents->blocked_content_tab_helper();
2123 *count = static_cast<int>(blocked_content->GetBlockedContentsCount()); 2123 *count = static_cast<int>(blocked_content->GetBlockedContentsCount());
2124 } 2124 }
2125 } 2125 }
2126 } 2126 }
2127 2127
2128 void TestingAutomationProvider::SendJSONRequest(int handle, 2128 void TestingAutomationProvider::SendJSONRequest(int handle,
2129 const std::string& json_request, 2129 const std::string& json_request,
2130 IPC::Message* reply_message) { 2130 IPC::Message* reply_message) {
2131 scoped_ptr<Value> values;
2132 base::JSONReader reader;
2133 std::string error; 2131 std::string error;
2134 values.reset(reader.ReadAndReturnError(json_request, 2132 scoped_ptr<Value> values(base::JSONReader::ReadAndReturnError(json_request,
2135 base::JSON_ALLOW_TRAILING_COMMAS, NULL, &error)); 2133 base::JSON_ALLOW_TRAILING_COMMAS, NULL, &error));
2136 if (!error.empty()) { 2134 if (!error.empty()) {
2137 AutomationJSONReply(this, reply_message).SendError(error); 2135 AutomationJSONReply(this, reply_message).SendError(error);
2138 return; 2136 return;
2139 } 2137 }
2140 2138
2141 // Make sure input is a dict with a string command. 2139 // Make sure input is a dict with a string command.
2142 std::string command; 2140 std::string command;
2143 DictionaryValue* dict_value = NULL; 2141 DictionaryValue* dict_value = NULL;
2144 if (values->GetType() != Value::TYPE_DICTIONARY) { 2142 if (values->GetType() != Value::TYPE_DICTIONARY) {
(...skipping 4969 matching lines...) Expand 10 before | Expand all | Expand 10 after
7114 *browser_handle = browser_tracker_->Add(browser); 7112 *browser_handle = browser_tracker_->Add(browser);
7115 *success = true; 7113 *success = true;
7116 } 7114 }
7117 } 7115 }
7118 } 7116 }
7119 7117
7120 void TestingAutomationProvider::OnRemoveProvider() { 7118 void TestingAutomationProvider::OnRemoveProvider() {
7121 if (g_browser_process) 7119 if (g_browser_process)
7122 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); 7120 g_browser_process->GetAutomationProviderList()->RemoveProvider(this);
7123 } 7121 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698