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 categorizing transactions for reporting in histograms. Patterns |
| 178 // cover relatively common use cases being measured and considered for |
| 179 // optimization. Many use cases that are more complex or uncommon are binned |
| 180 // as PATTERN_NOT_COVERED, and details are not reported. |
| 181 enum TransactionPattern { |
| 182 PATTERN_UNDEFINED, |
| 183 PATTERN_NOT_COVERED, |
| 184 PATTERN_ENTRY_NOT_CACHED, |
| 185 PATTERN_ENTRY_USED, |
| 186 PATTERN_ENTRY_VALIDATED, |
| 187 PATTERN_ENTRY_UPDATED, |
| 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 void UpdateTransactionPattern(TransactionPattern new_transaction_pattern); |
| 351 |
| 352 // Called on completion of a request to record performance. |
| 353 void RecordHistograms(); |
| 354 |
337 State next_state_; | 355 State next_state_; |
338 const HttpRequestInfo* request_; | 356 const HttpRequestInfo* request_; |
339 BoundNetLog net_log_; | 357 BoundNetLog net_log_; |
340 scoped_ptr<HttpRequestInfo> custom_request_; | 358 scoped_ptr<HttpRequestInfo> custom_request_; |
341 HttpRequestHeaders request_headers_copy_; | 359 HttpRequestHeaders request_headers_copy_; |
342 // If extra_headers specified a "if-modified-since" or "if-none-match", | 360 // If extra_headers specified a "if-modified-since" or "if-none-match", |
343 // |external_validation_| contains the value of those headers. | 361 // |external_validation_| contains the value of those headers. |
344 ValidationHeaders external_validation_; | 362 ValidationHeaders external_validation_; |
345 base::WeakPtr<HttpCache> cache_; | 363 base::WeakPtr<HttpCache> cache_; |
346 HttpCache::ActiveEntry* entry_; | 364 HttpCache::ActiveEntry* entry_; |
347 base::TimeTicks entry_lock_waiting_since_; | |
348 HttpCache::ActiveEntry* new_entry_; | 365 HttpCache::ActiveEntry* new_entry_; |
349 scoped_ptr<HttpTransaction> network_trans_; | 366 scoped_ptr<HttpTransaction> network_trans_; |
350 CompletionCallback callback_; // Consumer's callback. | 367 CompletionCallback callback_; // Consumer's callback. |
351 HttpResponseInfo response_; | 368 HttpResponseInfo response_; |
352 HttpResponseInfo auth_response_; | 369 HttpResponseInfo auth_response_; |
353 const HttpResponseInfo* new_response_; | 370 const HttpResponseInfo* new_response_; |
354 std::string cache_key_; | 371 std::string cache_key_; |
355 Mode mode_; | 372 Mode mode_; |
356 State target_state_; | 373 State target_state_; |
357 bool reading_; // We are already reading. | 374 bool reading_; // We are already reading. |
358 bool invalid_range_; // We may bypass the cache for this request. | 375 bool invalid_range_; // We may bypass the cache for this request. |
359 bool truncated_; // We don't have all the response data. | 376 bool truncated_; // We don't have all the response data. |
360 bool is_sparse_; // The data is stored in sparse byte ranges. | 377 bool is_sparse_; // The data is stored in sparse byte ranges. |
361 bool range_requested_; // The user requested a byte range. | 378 bool range_requested_; // The user requested a byte range. |
362 bool handling_206_; // We must deal with this 206 response. | 379 bool handling_206_; // We must deal with this 206 response. |
363 bool cache_pending_; // We are waiting for the HttpCache. | 380 bool cache_pending_; // We are waiting for the HttpCache. |
364 bool done_reading_; | 381 bool done_reading_; |
365 scoped_refptr<IOBuffer> read_buf_; | 382 scoped_refptr<IOBuffer> read_buf_; |
366 int io_buf_len_; | 383 int io_buf_len_; |
367 int read_offset_; | 384 int read_offset_; |
368 int effective_load_flags_; | 385 int effective_load_flags_; |
369 int write_len_; | 386 int write_len_; |
370 scoped_ptr<PartialData> partial_; // We are dealing with range requests. | 387 scoped_ptr<PartialData> partial_; // We are dealing with range requests. |
371 uint64 final_upload_progress_; | 388 uint64 final_upload_progress_; |
372 base::WeakPtrFactory<Transaction> weak_factory_; | 389 base::WeakPtrFactory<Transaction> weak_factory_; |
373 CompletionCallback io_callback_; | 390 CompletionCallback io_callback_; |
| 391 |
| 392 // Members used to track data for histograms. |
| 393 TransactionPattern transaction_pattern_; |
| 394 int bytes_read_from_cache_; |
| 395 int bytes_read_from_network_; |
| 396 base::TimeTicks entry_lock_waiting_since_; |
| 397 base::TimeTicks open_entry_since_; |
| 398 base::TimeTicks doom_entry_since_; |
| 399 base::TimeTicks send_request_since_; |
374 }; | 400 }; |
375 | 401 |
376 } // namespace net | 402 } // namespace net |
377 | 403 |
378 #endif // NET_HTTP_HTTP_CACHE_TRANSACTION_H_ | 404 #endif // NET_HTTP_HTTP_CACHE_TRANSACTION_H_ |
OLD | NEW |