| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/net/sdch_dictionary_fetcher.h" | 5 #include "chrome/browser/net/sdch_dictionary_fetcher.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "content/common/net/url_fetcher.h" |
| 9 #include "net/url_request/url_request_status.h" | 10 #include "net/url_request/url_request_status.h" |
| 10 | 11 |
| 11 SdchDictionaryFetcher::SdchDictionaryFetcher() | 12 SdchDictionaryFetcher::SdchDictionaryFetcher() |
| 12 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), | 13 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), |
| 13 task_is_pending_(false) { | 14 task_is_pending_(false) { |
| 14 } | 15 } |
| 15 | 16 |
| 16 SdchDictionaryFetcher::~SdchDictionaryFetcher() { | 17 SdchDictionaryFetcher::~SdchDictionaryFetcher() { |
| 17 } | 18 } |
| 18 | 19 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 current_fetch_.reset(new URLFetcher(fetch_queue_.front(), URLFetcher::GET, | 67 current_fetch_.reset(new URLFetcher(fetch_queue_.front(), URLFetcher::GET, |
| 67 this)); | 68 this)); |
| 68 fetch_queue_.pop(); | 69 fetch_queue_.pop(); |
| 69 current_fetch_->set_request_context(context); | 70 current_fetch_->set_request_context(context); |
| 70 current_fetch_->Start(); | 71 current_fetch_->Start(); |
| 71 } | 72 } |
| 72 | 73 |
| 73 void SdchDictionaryFetcher::OnURLFetchComplete(const URLFetcher* source) { | 74 void SdchDictionaryFetcher::OnURLFetchComplete(const URLFetcher* source) { |
| 74 if ((200 == source->response_code()) && | 75 if ((200 == source->response_code()) && |
| 75 (source->status().status() == net::URLRequestStatus::SUCCESS)) { | 76 (source->status().status() == net::URLRequestStatus::SUCCESS)) { |
| 76 net::SdchManager::Global()->AddSdchDictionary( | 77 std::string data; |
| 77 source->GetResponseStringRef(), | 78 CHECK(source->GetResponseAsString(&data)); |
| 78 source->url()); | 79 net::SdchManager::Global()->AddSdchDictionary(data, source->url()); |
| 79 } | 80 } |
| 80 current_fetch_.reset(NULL); | 81 current_fetch_.reset(NULL); |
| 81 ScheduleDelayedRun(); | 82 ScheduleDelayedRun(); |
| 82 } | 83 } |
| OLD | NEW |