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

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

Issue 1117703002: Adjust URLFetcher::Create API so that object is returned as scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix another failure missed by my regex Created 5 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
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/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 std::string api_key = base::GetQuotedJSONString(google_apis::GetAPIKey()); 83 std::string api_key = base::GetQuotedJSONString(google_apis::GetAPIKey());
84 std::string request = base::StringPrintf( 84 std::string request = base::StringPrintf(
85 kSpellingRequest, 85 kSpellingRequest,
86 type, 86 type,
87 encoded_text.c_str(), 87 encoded_text.c_str(),
88 language_code.c_str(), 88 language_code.c_str(),
89 country_code.c_str(), 89 country_code.c_str(),
90 api_key.c_str()); 90 api_key.c_str());
91 91
92 GURL url = GURL(kSpellingServiceURL); 92 GURL url = GURL(kSpellingServiceURL);
93 net::URLFetcher* fetcher = CreateURLFetcher(url); 93 net::URLFetcher* fetcher = CreateURLFetcher(url).release();
Ryan Sleevi 2015/04/30 18:23:44 line 98
94 fetcher->SetRequestContext(context->GetRequestContext()); 94 fetcher->SetRequestContext(context->GetRequestContext());
95 fetcher->SetUploadData("application/json", request); 95 fetcher->SetUploadData("application/json", request);
96 fetcher->SetLoadFlags( 96 fetcher->SetLoadFlags(
97 net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES); 97 net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES);
98 spellcheck_fetchers_[fetcher] = new TextCheckCallbackData(callback, text); 98 spellcheck_fetchers_[fetcher] = new TextCheckCallbackData(callback, text);
99 fetcher->Start(); 99 fetcher->Start();
100 return true; 100 return true;
101 } 101 }
102 102
103 bool SpellingServiceClient::IsAvailable( 103 bool SpellingServiceClient::IsAvailable(
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 fetcher->GetResponseAsString(&data); 246 fetcher->GetResponseAsString(&data);
247 success = ParseResponse(data, &results); 247 success = ParseResponse(data, &results);
248 } 248 }
249 spellcheck_fetchers_.erase(fetcher.get()); 249 spellcheck_fetchers_.erase(fetcher.get());
250 250
251 // The callback may release the last (transitive) dependency on |this|. It 251 // The callback may release the last (transitive) dependency on |this|. It
252 // MUST be the last function called. 252 // MUST be the last function called.
253 callback_data->callback.Run(success, callback_data->text, results); 253 callback_data->callback.Run(success, callback_data->text, results);
254 } 254 }
255 255
256 net::URLFetcher* SpellingServiceClient::CreateURLFetcher(const GURL& url) { 256 scoped_ptr<net::URLFetcher> SpellingServiceClient::CreateURLFetcher(
257 const GURL& url) {
257 return net::URLFetcher::Create(url, net::URLFetcher::POST, this); 258 return net::URLFetcher::Create(url, net::URLFetcher::POST, this);
258 } 259 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698