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 // This file declares HttpCache::Transaction, a private class of HttpCache so | 5 // This file declares HttpCache::Transaction, a private class of HttpCache so |
6 // it should only be included by http_cache.cc | 6 // it should only be included by http_cache.cc |
7 | 7 |
8 #ifndef NET_HTTP_HTTP_CACHE_TRANSACTION_H_ | 8 #ifndef NET_HTTP_HTTP_CACHE_TRANSACTION_H_ |
9 #define NET_HTTP_HTTP_CACHE_TRANSACTION_H_ | 9 #define NET_HTTP_HTTP_CACHE_TRANSACTION_H_ |
10 | 10 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 STATE_CACHE_READ_METADATA, | 167 STATE_CACHE_READ_METADATA, |
168 STATE_CACHE_READ_METADATA_COMPLETE, | 168 STATE_CACHE_READ_METADATA_COMPLETE, |
169 STATE_CACHE_QUERY_DATA, | 169 STATE_CACHE_QUERY_DATA, |
170 STATE_CACHE_QUERY_DATA_COMPLETE, | 170 STATE_CACHE_QUERY_DATA_COMPLETE, |
171 STATE_CACHE_READ_DATA, | 171 STATE_CACHE_READ_DATA, |
172 STATE_CACHE_READ_DATA_COMPLETE, | 172 STATE_CACHE_READ_DATA_COMPLETE, |
173 STATE_CACHE_WRITE_DATA, | 173 STATE_CACHE_WRITE_DATA, |
174 STATE_CACHE_WRITE_DATA_COMPLETE | 174 STATE_CACHE_WRITE_DATA_COMPLETE |
175 }; | 175 }; |
176 | 176 |
| 177 // Used for reporting times in histograms. The dispositions cover relatively |
| 178 // common simple cases for cache resource requests, but are not intended to be |
| 179 // exhaustive; many tricky special cases are all binned together as |
| 180 // DISPOSITION_DO_NOT_RECORD. |
| 181 enum Disposition { |
| 182 DISPOSITION_UNDEFINED, |
| 183 DISPOSITION_DO_NOT_RECORD, |
| 184 DISPOSITION_NO_ENTRY, |
| 185 DISPOSITION_ENTRY_UNCONDITIONALLY_USED, |
| 186 DISPOSITION_ENTRY_VALIDATED_304, |
| 187 DISPOSITION_ENTRY_VALIDATED_200, |
| 188 }; |
| 189 |
177 // This is a helper function used to trigger a completion callback. It may | 190 // This is a helper function used to trigger a completion callback. It may |
178 // only be called if callback_ is non-null. | 191 // only be called if callback_ is non-null. |
179 void DoCallback(int rv); | 192 void DoCallback(int rv); |
180 | 193 |
181 // This will trigger the completion callback if appropriate. | 194 // This will trigger the completion callback if appropriate. |
182 int HandleResult(int rv); | 195 int HandleResult(int rv); |
183 | 196 |
184 // Runs the state transition loop. | 197 // Runs the state transition loop. |
185 int DoLoop(int result); | 198 int DoLoop(int result); |
186 | 199 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 int DoPartialCacheReadCompleted(int result); | 340 int DoPartialCacheReadCompleted(int result); |
328 | 341 |
329 // Returns true if we should bother attempting to resume this request if it | 342 // Returns true if we should bother attempting to resume this request if it |
330 // is aborted while in progress. If |has_data| is true, the size of the stored | 343 // is aborted while in progress. If |has_data| is true, the size of the stored |
331 // data is considered for the result. | 344 // data is considered for the result. |
332 bool CanResume(bool has_data); | 345 bool CanResume(bool has_data); |
333 | 346 |
334 // Called to signal completion of asynchronous IO. | 347 // Called to signal completion of asynchronous IO. |
335 void OnIOComplete(int result); | 348 void OnIOComplete(int result); |
336 | 349 |
| 350 // Called when we've determined the disposition of this request. |
| 351 void MaybeUpdateDisposition(Disposition disposition); |
| 352 |
| 353 // Called on completion of a request to record performance. |
| 354 void RecordHistograms(int resource_size); |
| 355 |
337 State next_state_; | 356 State next_state_; |
338 const HttpRequestInfo* request_; | 357 const HttpRequestInfo* request_; |
339 BoundNetLog net_log_; | 358 BoundNetLog net_log_; |
340 scoped_ptr<HttpRequestInfo> custom_request_; | 359 scoped_ptr<HttpRequestInfo> custom_request_; |
341 HttpRequestHeaders request_headers_copy_; | 360 HttpRequestHeaders request_headers_copy_; |
342 // If extra_headers specified a "if-modified-since" or "if-none-match", | 361 // If extra_headers specified a "if-modified-since" or "if-none-match", |
343 // |external_validation_| contains the value of those headers. | 362 // |external_validation_| contains the value of those headers. |
344 ValidationHeaders external_validation_; | 363 ValidationHeaders external_validation_; |
345 base::WeakPtr<HttpCache> cache_; | 364 base::WeakPtr<HttpCache> cache_; |
346 HttpCache::ActiveEntry* entry_; | 365 HttpCache::ActiveEntry* entry_; |
347 base::TimeTicks entry_lock_waiting_since_; | |
348 HttpCache::ActiveEntry* new_entry_; | 366 HttpCache::ActiveEntry* new_entry_; |
349 scoped_ptr<HttpTransaction> network_trans_; | 367 scoped_ptr<HttpTransaction> network_trans_; |
350 CompletionCallback callback_; // Consumer's callback. | 368 CompletionCallback callback_; // Consumer's callback. |
351 HttpResponseInfo response_; | 369 HttpResponseInfo response_; |
352 HttpResponseInfo auth_response_; | 370 HttpResponseInfo auth_response_; |
353 const HttpResponseInfo* new_response_; | 371 const HttpResponseInfo* new_response_; |
354 std::string cache_key_; | 372 std::string cache_key_; |
355 Mode mode_; | 373 Mode mode_; |
356 State target_state_; | 374 State target_state_; |
357 bool reading_; // We are already reading. | 375 bool reading_; // We are already reading. |
358 bool invalid_range_; // We may bypass the cache for this request. | 376 bool invalid_range_; // We may bypass the cache for this request. |
359 bool truncated_; // We don't have all the response data. | 377 bool truncated_; // We don't have all the response data. |
360 bool is_sparse_; // The data is stored in sparse byte ranges. | 378 bool is_sparse_; // The data is stored in sparse byte ranges. |
361 bool range_requested_; // The user requested a byte range. | 379 bool range_requested_; // The user requested a byte range. |
362 bool handling_206_; // We must deal with this 206 response. | 380 bool handling_206_; // We must deal with this 206 response. |
363 bool cache_pending_; // We are waiting for the HttpCache. | 381 bool cache_pending_; // We are waiting for the HttpCache. |
364 bool done_reading_; | 382 bool done_reading_; |
365 scoped_refptr<IOBuffer> read_buf_; | 383 scoped_refptr<IOBuffer> read_buf_; |
366 int io_buf_len_; | 384 int io_buf_len_; |
367 int read_offset_; | 385 int read_offset_; |
368 int effective_load_flags_; | 386 int effective_load_flags_; |
369 int write_len_; | 387 int write_len_; |
370 scoped_ptr<PartialData> partial_; // We are dealing with range requests. | 388 scoped_ptr<PartialData> partial_; // We are dealing with range requests. |
371 uint64 final_upload_progress_; | 389 uint64 final_upload_progress_; |
372 base::WeakPtrFactory<Transaction> weak_factory_; | 390 base::WeakPtrFactory<Transaction> weak_factory_; |
373 CompletionCallback io_callback_; | 391 CompletionCallback io_callback_; |
| 392 |
| 393 // Members used to track data for histograms. |
| 394 Disposition disposition_; |
| 395 base::TimeTicks entry_lock_waiting_since_; |
| 396 base::TimeTicks open_entry_since_; |
| 397 base::TimeTicks started_reading_since_; |
374 }; | 398 }; |
375 | 399 |
376 } // namespace net | 400 } // namespace net |
377 | 401 |
378 #endif // NET_HTTP_HTTP_CACHE_TRANSACTION_H_ | 402 #endif // NET_HTTP_HTTP_CACHE_TRANSACTION_H_ |
OLD | NEW |