OLD | NEW |
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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/json/string_escape.h" | 9 #include "base/json/string_escape.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 scoped_ptr<const net::URLFetcher> fetcher(source); | 247 scoped_ptr<const net::URLFetcher> fetcher(source); |
248 scoped_ptr<TextCheckCallbackData> | 248 scoped_ptr<TextCheckCallbackData> |
249 callback_data(spellcheck_fetchers_[fetcher.get()]); | 249 callback_data(spellcheck_fetchers_[fetcher.get()]); |
250 bool success = false; | 250 bool success = false; |
251 std::vector<SpellCheckResult> results; | 251 std::vector<SpellCheckResult> results; |
252 if (fetcher->GetResponseCode() / 100 == 2) { | 252 if (fetcher->GetResponseCode() / 100 == 2) { |
253 std::string data; | 253 std::string data; |
254 fetcher->GetResponseAsString(&data); | 254 fetcher->GetResponseAsString(&data); |
255 success = ParseResponse(data, &results); | 255 success = ParseResponse(data, &results); |
256 } | 256 } |
| 257 spellcheck_fetchers_.erase(fetcher.get()); |
| 258 |
| 259 // The callback may release the last (transitive) dependency on |this|. It |
| 260 // MUST be the last function called. |
257 callback_data->callback.Run(success, callback_data->text, results); | 261 callback_data->callback.Run(success, callback_data->text, results); |
258 spellcheck_fetchers_.erase(fetcher.get()); | |
259 } | 262 } |
260 | 263 |
261 net::URLFetcher* SpellingServiceClient::CreateURLFetcher(const GURL& url) { | 264 net::URLFetcher* SpellingServiceClient::CreateURLFetcher(const GURL& url) { |
262 return net::URLFetcher::Create(url, net::URLFetcher::POST, this); | 265 return net::URLFetcher::Create(url, net::URLFetcher::POST, this); |
263 } | 266 } |
OLD | NEW |