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

Side by Side Diff: chrome/browser/spellchecker/spelling_service_client.cc

Issue 10392192: Remove content::URLFetcherDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More cleanup 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/spellchecker/spelling_service_client.h" 5 #include "chrome/browser/spellchecker/spelling_service_client.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/json/string_escape.h" 8 #include "base/json/string_escape.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 fetcher_->SetLoadFlags( 103 fetcher_->SetLoadFlags(
104 net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES); 104 net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES);
105 fetcher_->Start(); 105 fetcher_->Start();
106 tag_ = tag; 106 tag_ = tag;
107 callback_ = callback; 107 callback_ = callback;
108 return true; 108 return true;
109 } 109 }
110 110
111 void SpellingServiceClient::OnURLFetchComplete( 111 void SpellingServiceClient::OnURLFetchComplete(
112 const net::URLFetcher* source) { 112 const net::URLFetcher* source) {
113 scoped_ptr<content::URLFetcher> clean_up_fetcher(fetcher_.release()); 113 scoped_ptr<net::URLFetcher> clean_up_fetcher(fetcher_.release());
114 bool success = false; 114 bool success = false;
115 std::vector<SpellCheckResult> results; 115 std::vector<SpellCheckResult> results;
116 if (source->GetResponseCode() / 100 == 2) { 116 if (source->GetResponseCode() / 100 == 2) {
117 std::string data; 117 std::string data;
118 source->GetResponseAsString(&data); 118 source->GetResponseAsString(&data);
119 success = ParseResponse(data, &results); 119 success = ParseResponse(data, &results);
120 } 120 }
121 callback_.Run(tag_, success, results); 121 callback_.Run(tag_, success, results);
122 } 122 }
123 123
124 content::URLFetcher* SpellingServiceClient::CreateURLFetcher(const GURL& url) { 124 net::URLFetcher* SpellingServiceClient::CreateURLFetcher(const GURL& url) {
125 return content::URLFetcher::Create(url, content::URLFetcher::POST, this); 125 return content::URLFetcher::Create(url, content::URLFetcher::POST, this);
126 } 126 }
127 127
128 bool SpellingServiceClient::ParseResponse( 128 bool SpellingServiceClient::ParseResponse(
129 const std::string& data, 129 const std::string& data,
130 std::vector<SpellCheckResult>* results) { 130 std::vector<SpellCheckResult>* results) {
131 // When this JSON-RPC call finishes successfully, the Spelling service returns 131 // When this JSON-RPC call finishes successfully, the Spelling service returns
132 // an JSON object listed below. 132 // an JSON object listed below.
133 // * result - an envelope object representing the result from the APIARY 133 // * result - an envelope object representing the result from the APIARY
134 // server, which is the JSON-API front-end for the Spelling service. This 134 // server, which is the JSON-API front-end for the Spelling service. This
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 if (!suggestions->GetDictionary(0, &suggestion) || 195 if (!suggestions->GetDictionary(0, &suggestion) ||
196 !suggestion->GetString("suggestion", &replacement)) { 196 !suggestion->GetString("suggestion", &replacement)) {
197 return false; 197 return false;
198 } 198 }
199 SpellCheckResult result( 199 SpellCheckResult result(
200 SpellCheckResult::SPELLING, start, length, replacement); 200 SpellCheckResult::SPELLING, start, length, replacement);
201 results->push_back(result); 201 results->push_back(result);
202 } 202 }
203 return true; 203 return true;
204 } 204 }
OLDNEW
« no previous file with comments | « chrome/browser/spellchecker/spelling_service_client.h ('k') | chrome/browser/spellchecker/spelling_service_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698