OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "net/url_request/sdch_dictionary_fetcher.h" | 5 #include "net/url_request/sdch_dictionary_fetcher.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 // TODO(rdsmith): log this error to the net log of the URLRequest | 53 // TODO(rdsmith): log this error to the net log of the URLRequest |
54 // initiating this fetch, once URLRequest will be passed here. | 54 // initiating this fetch, once URLRequest will be passed here. |
55 SdchManager::SdchErrorRecovery( | 55 SdchManager::SdchErrorRecovery( |
56 SDCH_DICTIONARY_PREVIOUSLY_SCHEDULED_TO_DOWNLOAD); | 56 SDCH_DICTIONARY_PREVIOUSLY_SCHEDULED_TO_DOWNLOAD); |
57 return; | 57 return; |
58 } | 58 } |
59 | 59 |
60 attempted_load_.insert(dictionary_url); | 60 attempted_load_.insert(dictionary_url); |
61 fetch_queue_.push(dictionary_url); | 61 fetch_queue_.push(dictionary_url); |
62 | 62 |
63 next_state_ = STATE_IDLE; | 63 // If the loop is already processing, it'll pick up the above in the |
64 // normal course of events. If it isn't processing, we kick it off. | |
65 if (next_state_ == STATE_NONE) { | |
mmenke
2015/01/21 21:33:57
I think an early return is cleaner here.
Randy Smith (Not in Mondays)
2015/01/22 19:04:39
Right you are. Done.
| |
66 next_state_ = STATE_IDLE; | |
mmenke
2015/01/21 21:33:57
It's a bit tangential to this CL, but while we're
Randy Smith (Not in Mondays)
2015/01/22 19:04:39
Naming changes, while they touch a lot of lines, d
mmenke
2015/01/22 19:58:32
I'd go with:
STATE_IDLE => STATE_SEND_REQUEST / D
mmenke
2015/01/24 17:01:24
And a quick followup about my reasoning: I think
Randy Smith (Not in Mondays)
2015/01/24 23:21:01
Yes, that makes sense to me (and was appealing to
| |
64 | 67 |
65 // There are no callbacks to user code from the dictionary fetcher, | 68 // There are no callbacks to user code from the dictionary fetcher, |
66 // and Schedule() is only called from user code, so this call to DoLoop() | 69 // and Schedule() is only called from user code, so this call to DoLoop() |
67 // does not require an |if (in_loop_) return;| guard. | 70 // does not require an |if (in_loop_) return;| guard. |
68 DoLoop(OK); | 71 DoLoop(OK); |
72 } | |
69 } | 73 } |
70 | 74 |
71 void SdchDictionaryFetcher::Cancel() { | 75 void SdchDictionaryFetcher::Cancel() { |
72 DCHECK(CalledOnValidThread()); | 76 DCHECK(CalledOnValidThread()); |
73 | 77 |
74 next_state_ = STATE_NONE; | 78 next_state_ = STATE_NONE; |
75 | 79 |
76 while (!fetch_queue_.empty()) | 80 while (!fetch_queue_.empty()) |
77 fetch_queue_.pop(); | 81 fetch_queue_.pop(); |
78 attempted_load_.clear(); | 82 attempted_load_.clear(); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
250 current_request_.reset(); | 254 current_request_.reset(); |
251 buffer_ = NULL; | 255 buffer_ = NULL; |
252 dictionary_.clear(); | 256 dictionary_.clear(); |
253 | 257 |
254 next_state_ = STATE_IDLE; | 258 next_state_ = STATE_IDLE; |
255 | 259 |
256 return OK; | 260 return OK; |
257 } | 261 } |
258 | 262 |
259 } // namespace net | 263 } // namespace net |
OLD | NEW |