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

Side by Side Diff: net/url_request/sdch_dictionary_fetcher.cc

Issue 2315613002: Extracted NetLog class's inner enum types into their own enum classes and (Closed)
Patch Set: Ran "git cl format" on code. Much formatting ensued. Created 4 years, 3 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
« no previous file with comments | « net/udp/udp_socket_win.cc ('k') | net/url_request/url_request.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <queue> 8 #include <queue>
9 #include <set> 9 #include <set>
10 10
11 #include "base/auto_reset.h" 11 #include "base/auto_reset.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/threading/thread_task_runner_handle.h" 15 #include "base/threading/thread_task_runner_handle.h"
16 #include "net/base/io_buffer.h" 16 #include "net/base/io_buffer.h"
17 #include "net/base/load_flags.h" 17 #include "net/base/load_flags.h"
18 #include "net/base/sdch_net_log_params.h" 18 #include "net/base/sdch_net_log_params.h"
19 #include "net/http/http_response_headers.h" 19 #include "net/http/http_response_headers.h"
20 #include "net/log/net_log.h" 20 #include "net/log/net_log.h"
21 #include "net/log/net_log_event_type.h"
21 #include "net/url_request/redirect_info.h" 22 #include "net/url_request/redirect_info.h"
22 #include "net/url_request/url_request_context.h" 23 #include "net/url_request/url_request_context.h"
23 #include "net/url_request/url_request_status.h" 24 #include "net/url_request/url_request_status.h"
24 #include "net/url_request/url_request_throttler_manager.h" 25 #include "net/url_request/url_request_throttler_manager.h"
25 26
26 namespace net { 27 namespace net {
27 28
28 namespace { 29 namespace {
29 30
30 const int kBufferSize = 4096; 31 const int kBufferSize = 4096;
31 32
32 // Map the bytes_read result from a read attempt and a URLRequest's 33 // Map the bytes_read result from a read attempt and a URLRequest's
33 // status into a single net return value. 34 // status into a single net return value.
34 int GetReadResult(int bytes_read, const URLRequest* request) { 35 int GetReadResult(int bytes_read, const URLRequest* request) {
35 int rv = request->status().error(); 36 int rv = request->status().error();
36 if (request->status().is_success() && bytes_read < 0) { 37 if (request->status().is_success() && bytes_read < 0) {
37 rv = ERR_FAILED; 38 rv = ERR_FAILED;
38 request->net_log().AddEventWithNetErrorCode( 39 request->net_log().AddEventWithNetErrorCode(
39 NetLog::TYPE_SDCH_DICTIONARY_FETCH_IMPLIED_ERROR, rv); 40 NetLogEventType::SDCH_DICTIONARY_FETCH_IMPLIED_ERROR, rv);
40 } 41 }
41 42
42 if (rv == OK) 43 if (rv == OK)
43 rv = bytes_read; 44 rv = bytes_read;
44 45
45 return rv; 46 return rv;
46 } 47 }
47 48
48 struct FetchInfo { 49 struct FetchInfo {
49 FetchInfo(const GURL& url, 50 FetchInfo(const GURL& url,
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 int load_flags = LOAD_DO_NOT_SEND_COOKIES | LOAD_DO_NOT_SAVE_COOKIES; 284 int load_flags = LOAD_DO_NOT_SEND_COOKIES | LOAD_DO_NOT_SAVE_COOKIES;
284 if (info.cache_only) 285 if (info.cache_only)
285 load_flags |= LOAD_ONLY_FROM_CACHE; 286 load_flags |= LOAD_ONLY_FROM_CACHE;
286 current_request_->SetLoadFlags(load_flags); 287 current_request_->SetLoadFlags(load_flags);
287 288
288 buffer_ = new IOBuffer(kBufferSize); 289 buffer_ = new IOBuffer(kBufferSize);
289 dictionary_.reset(new std::string()); 290 dictionary_.reset(new std::string());
290 current_callback_ = info.callback; 291 current_callback_ = info.callback;
291 292
292 current_request_->Start(); 293 current_request_->Start();
293 current_request_->net_log().AddEvent(NetLog::TYPE_SDCH_DICTIONARY_FETCH); 294 current_request_->net_log().AddEvent(NetLogEventType::SDCH_DICTIONARY_FETCH);
294 295
295 return ERR_IO_PENDING; 296 return ERR_IO_PENDING;
296 } 297 }
297 298
298 int SdchDictionaryFetcher::DoReceivedRedirect(int rv) { 299 int SdchDictionaryFetcher::DoReceivedRedirect(int rv) {
299 // Fetching SDCH through a redirect is forbidden; it raises possible 300 // Fetching SDCH through a redirect is forbidden; it raises possible
300 // security issues cross-origin, and isn't obviously useful within 301 // security issues cross-origin, and isn't obviously useful within
301 // an origin. 302 // an origin.
302 ResetRequest(); 303 ResetRequest();
303 next_state_ = STATE_SEND_REQUEST; 304 next_state_ = STATE_SEND_REQUEST;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 current_request_->net_log(), 371 current_request_->net_log(),
371 current_request_->was_cached()); 372 current_request_->was_cached());
372 } 373 }
373 374
374 ResetRequest(); 375 ResetRequest();
375 next_state_ = STATE_SEND_REQUEST; 376 next_state_ = STATE_SEND_REQUEST;
376 return OK; 377 return OK;
377 } 378 }
378 379
379 } // namespace net 380 } // namespace net
OLDNEW
« no previous file with comments | « net/udp/udp_socket_win.cc ('k') | net/url_request/url_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698