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

Side by Side Diff: chrome/browser/autocomplete/search_provider.cc

Issue 16270: Change the signature of JSONReader::Read() and related methods to be more (Closed)
Patch Set: fixens Created 11 years, 12 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 (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/autocomplete/search_provider.h" 5 #include "chrome/browser/autocomplete/search_provider.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/google_util.h" 10 #include "chrome/browser/google_util.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 std::string charset; 122 std::string charset;
123 if (response_headers->GetCharset(&charset)) { 123 if (response_headers->GetCharset(&charset)) {
124 std::wstring wide_data; 124 std::wstring wide_data;
125 // TODO(jungshik): Switch to CodePageToUTF8 after it's added. 125 // TODO(jungshik): Switch to CodePageToUTF8 after it's added.
126 if (CodepageToWide(data, charset.c_str(), 126 if (CodepageToWide(data, charset.c_str(),
127 OnStringUtilConversionError::FAIL, &wide_data)) 127 OnStringUtilConversionError::FAIL, &wide_data))
128 json_data = WideToUTF8(wide_data); 128 json_data = WideToUTF8(wide_data);
129 } 129 }
130 } 130 }
131 131
132 JSONStringValueSerializer deserializer(json_data); 132 if (status.is_success() && response_code == 200) {
133 deserializer.set_allow_trailing_comma(true); 133 JSONStringValueSerializer deserializer(json_data);
134 Value* root_val = NULL; 134 deserializer.set_allow_trailing_comma(true);
135 have_suggest_results_ = status.is_success() && (response_code == 200) && 135 scoped_ptr<Value> root_val(deserializer.Deserialize(NULL));
136 deserializer.Deserialize(&root_val, NULL) && 136 have_suggest_results_ =
137 ParseSuggestResults(root_val); 137 root_val.get() && ParseSuggestResults(root_val.get());
138 delete root_val; 138 }
139
139 ConvertResultsToAutocompleteMatches(); 140 ConvertResultsToAutocompleteMatches();
140 listener_->OnProviderUpdate(!suggest_results_.empty()); 141 listener_->OnProviderUpdate(!suggest_results_.empty());
141 } 142 }
142 143
143 void SearchProvider::StartOrStopHistoryQuery(bool minimal_changes) { 144 void SearchProvider::StartOrStopHistoryQuery(bool minimal_changes) {
144 // For the minimal_changes case, if we finished the previous query and still 145 // For the minimal_changes case, if we finished the previous query and still
145 // have its results, or are allowed to keep running it, just do that, rather 146 // have its results, or are allowed to keep running it, just do that, rather
146 // than starting a new query. 147 // than starting a new query.
147 if (minimal_changes && 148 if (minimal_changes &&
148 (have_history_results_ || (!done_ && !input_.synchronous_only()))) 149 (have_history_results_ || (!done_ && !input_.synchronous_only())))
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 const size_t after_slashes = std::min(url->length(), 605 const size_t after_slashes = std::min(url->length(),
605 static_cast<size_t>(scheme.end() + 3)); 606 static_cast<size_t>(scheme.end() + 3));
606 while ((prefix_len < after_slashes) && ((*url)[prefix_len] == L'/')) 607 while ((prefix_len < after_slashes) && ((*url)[prefix_len] == L'/'))
607 ++prefix_len; 608 ++prefix_len;
608 if (prefix_len == url->length()) 609 if (prefix_len == url->length())
609 url->clear(); 610 url->clear();
610 else 611 else
611 url->erase(url->begin(), url->begin() + prefix_len); 612 url->erase(url->begin(), url->begin() + prefix_len);
612 return prefix_len; 613 return prefix_len;
613 } 614 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698