Chromium Code Reviews| 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 #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_event_type.h" | 20 #include "net/log/net_log_event_type.h" |
| 21 #include "net/log/net_log_with_source.h" | 21 #include "net/log/net_log_with_source.h" |
| 22 #include "net/traffic_annotation/network_traffic_annotation.h" | |
| 22 #include "net/url_request/redirect_info.h" | 23 #include "net/url_request/redirect_info.h" |
| 23 #include "net/url_request/url_request_context.h" | 24 #include "net/url_request/url_request_context.h" |
| 24 #include "net/url_request/url_request_status.h" | 25 #include "net/url_request/url_request_status.h" |
| 25 #include "net/url_request/url_request_throttler_manager.h" | 26 #include "net/url_request/url_request_throttler_manager.h" |
| 26 | 27 |
| 27 namespace net { | 28 namespace net { |
| 28 | 29 |
| 29 namespace { | 30 namespace { |
| 30 | 31 |
| 31 const int kBufferSize = 4096; | 32 const int kBufferSize = 4096; |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 271 if (fetch_queue_->IsEmpty() || current_request_.get()) { | 272 if (fetch_queue_->IsEmpty() || current_request_.get()) { |
| 272 next_state_ = STATE_NONE; | 273 next_state_ = STATE_NONE; |
| 273 return OK; | 274 return OK; |
| 274 } | 275 } |
| 275 | 276 |
| 276 next_state_ = STATE_SEND_REQUEST_PENDING; | 277 next_state_ = STATE_SEND_REQUEST_PENDING; |
| 277 | 278 |
| 278 FetchInfo info; | 279 FetchInfo info; |
| 279 bool success = fetch_queue_->Pop(&info); | 280 bool success = fetch_queue_->Pop(&info); |
| 280 DCHECK(success); | 281 DCHECK(success); |
| 281 current_request_ = context_->CreateRequest(info.url, IDLE, this); | 282 net::NetworkTrafficAnnotationTag traffic_annotation = |
| 283 net::DefineNetworkTrafficAnnotation("sdch_dictionary_fetch", R"( | |
| 284 semantics { | |
| 285 sender: "SDCH" | |
| 286 description: | |
| 287 "The Chrome Network Stack can use less bandwidth and reduce " | |
|
Randy Smith (Not in Mondays)
2017/05/03 12:58:42
nit: reduces. (My mistake.)
Ramin Halavati
2017/05/04 04:36:28
Done.
| |
| 288 "request latency if a dictionary shared between client and server " | |
| 289 "is used to compress content on the server before sending, and " | |
| 290 "decompress content on the client after reception. This request is " | |
| 291 "fetching such a dictionary; it is dispatched when the response to " | |
| 292 "a previous URL request indicated that there was a dictionary that " | |
| 293 "the client did not currently have in memory, and could be used " | |
| 294 "for compression." | |
| 295 trigger: | |
| 296 "A response to a previous URL request indicated that this URL " | |
| 297 "contained a dictionary that could be used to compress other URL " | |
| 298 "responses." | |
| 299 data: | |
| 300 "..." | |
| 301 destination: WEBSITE | |
| 302 } | |
| 303 policy { | |
| 304 cookies_allowed: false | |
| 305 setting: | |
| 306 "This feature is disabled in Chrome and can obly be enabled in non-" | |
|
Randy Smith (Not in Mondays)
2017/05/03 12:58:43
nit: only
Ramin Halavati
2017/05/04 04:36:28
Done.
| |
| 307 "Chromium embedders." | |
| 308 policy_exception_justification: | |
| 309 "Not implemented, not part of Chrome." | |
| 310 })"); | |
| 311 current_request_ = | |
| 312 context_->CreateRequest(info.url, IDLE, this, traffic_annotation); | |
| 282 int load_flags = LOAD_DO_NOT_SEND_COOKIES | LOAD_DO_NOT_SAVE_COOKIES; | 313 int load_flags = LOAD_DO_NOT_SEND_COOKIES | LOAD_DO_NOT_SAVE_COOKIES; |
| 283 if (info.cache_only) | 314 if (info.cache_only) |
| 284 load_flags |= LOAD_ONLY_FROM_CACHE | LOAD_SKIP_CACHE_VALIDATION; | 315 load_flags |= LOAD_ONLY_FROM_CACHE | LOAD_SKIP_CACHE_VALIDATION; |
| 285 current_request_->SetLoadFlags(load_flags); | 316 current_request_->SetLoadFlags(load_flags); |
| 286 | 317 |
| 287 buffer_ = new IOBuffer(kBufferSize); | 318 buffer_ = new IOBuffer(kBufferSize); |
| 288 dictionary_.reset(new std::string()); | 319 dictionary_.reset(new std::string()); |
| 289 current_callback_ = info.callback; | 320 current_callback_ = info.callback; |
| 290 | 321 |
| 291 current_request_->Start(); | 322 current_request_->Start(); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 368 current_request_->net_log(), | 399 current_request_->net_log(), |
| 369 current_request_->was_cached()); | 400 current_request_->was_cached()); |
| 370 } | 401 } |
| 371 | 402 |
| 372 ResetRequest(); | 403 ResetRequest(); |
| 373 next_state_ = STATE_SEND_REQUEST; | 404 next_state_ = STATE_SEND_REQUEST; |
| 374 return OK; | 405 return OK; |
| 375 } | 406 } |
| 376 | 407 |
| 377 } // namespace net | 408 } // namespace net |
| OLD | NEW |