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

Side by Side Diff: net/http/http_cache_transaction.h

Issue 10808047: Add HttpCache histograms focussed on blocking and transaction type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... how about a fix that compiles. Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « net/disk_cache/mem_backend_impl.cc ('k') | net/http/http_cache_transaction.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 (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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 STATE_CACHE_READ_METADATA, 168 STATE_CACHE_READ_METADATA,
169 STATE_CACHE_READ_METADATA_COMPLETE, 169 STATE_CACHE_READ_METADATA_COMPLETE,
170 STATE_CACHE_QUERY_DATA, 170 STATE_CACHE_QUERY_DATA,
171 STATE_CACHE_QUERY_DATA_COMPLETE, 171 STATE_CACHE_QUERY_DATA_COMPLETE,
172 STATE_CACHE_READ_DATA, 172 STATE_CACHE_READ_DATA,
173 STATE_CACHE_READ_DATA_COMPLETE, 173 STATE_CACHE_READ_DATA_COMPLETE,
174 STATE_CACHE_WRITE_DATA, 174 STATE_CACHE_WRITE_DATA,
175 STATE_CACHE_WRITE_DATA_COMPLETE 175 STATE_CACHE_WRITE_DATA_COMPLETE
176 }; 176 };
177 177
178 // Used for categorizing transactions for reporting in histograms. Patterns
179 // cover relatively common use cases being measured and considered for
180 // optimization. Many use cases that are more complex or uncommon are binned
181 // as PATTERN_NOT_COVERED, and details are not reported.
182 enum TransactionPattern {
183 PATTERN_UNDEFINED,
184 PATTERN_NOT_COVERED,
185 PATTERN_ENTRY_NOT_CACHED,
186 PATTERN_ENTRY_USED,
187 PATTERN_ENTRY_VALIDATED,
188 PATTERN_ENTRY_UPDATED,
189 };
190
178 // This is a helper function used to trigger a completion callback. It may 191 // This is a helper function used to trigger a completion callback. It may
179 // only be called if callback_ is non-null. 192 // only be called if callback_ is non-null.
180 void DoCallback(int rv); 193 void DoCallback(int rv);
181 194
182 // This will trigger the completion callback if appropriate. 195 // This will trigger the completion callback if appropriate.
183 int HandleResult(int rv); 196 int HandleResult(int rv);
184 197
185 // Runs the state transition loop. 198 // Runs the state transition loop.
186 int DoLoop(int result); 199 int DoLoop(int result);
187 200
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 // Returns true if we should bother attempting to resume this request if it 348 // Returns true if we should bother attempting to resume this request if it
336 // is aborted while in progress. If |has_data| is true, the size of the stored 349 // is aborted while in progress. If |has_data| is true, the size of the stored
337 // data is considered for the result. 350 // data is considered for the result.
338 bool CanResume(bool has_data); 351 bool CanResume(bool has_data);
339 352
340 // Called to signal completion of asynchronous IO. 353 // Called to signal completion of asynchronous IO.
341 void OnIOComplete(int result); 354 void OnIOComplete(int result);
342 355
343 void ReportCacheActionStart(); 356 void ReportCacheActionStart();
344 void ReportCacheActionFinish(); 357 void ReportCacheActionFinish();
358 void UpdateTransactionPattern(TransactionPattern new_transaction_pattern);
359 void RecordHistograms();
345 360
346 State next_state_; 361 State next_state_;
347 const HttpRequestInfo* request_; 362 const HttpRequestInfo* request_;
348 BoundNetLog net_log_; 363 BoundNetLog net_log_;
349 scoped_ptr<HttpRequestInfo> custom_request_; 364 scoped_ptr<HttpRequestInfo> custom_request_;
350 HttpRequestHeaders request_headers_copy_; 365 HttpRequestHeaders request_headers_copy_;
351 // If extra_headers specified a "if-modified-since" or "if-none-match", 366 // If extra_headers specified a "if-modified-since" or "if-none-match",
352 // |external_validation_| contains the value of those headers. 367 // |external_validation_| contains the value of those headers.
353 ValidationHeaders external_validation_; 368 ValidationHeaders external_validation_;
354 base::WeakPtr<HttpCache> cache_; 369 base::WeakPtr<HttpCache> cache_;
355 HttpCache::ActiveEntry* entry_; 370 HttpCache::ActiveEntry* entry_;
356 base::TimeTicks entry_lock_waiting_since_;
357 HttpCache::ActiveEntry* new_entry_; 371 HttpCache::ActiveEntry* new_entry_;
358 scoped_ptr<HttpTransaction> network_trans_; 372 scoped_ptr<HttpTransaction> network_trans_;
359 CompletionCallback callback_; // Consumer's callback. 373 CompletionCallback callback_; // Consumer's callback.
360 HttpResponseInfo response_; 374 HttpResponseInfo response_;
361 HttpResponseInfo auth_response_; 375 HttpResponseInfo auth_response_;
362 const HttpResponseInfo* new_response_; 376 const HttpResponseInfo* new_response_;
363 std::string cache_key_; 377 std::string cache_key_;
364 Mode mode_; 378 Mode mode_;
365 State target_state_; 379 State target_state_;
366 bool reading_; // We are already reading. 380 bool reading_; // We are already reading.
367 bool invalid_range_; // We may bypass the cache for this request. 381 bool invalid_range_; // We may bypass the cache for this request.
368 bool truncated_; // We don't have all the response data. 382 bool truncated_; // We don't have all the response data.
369 bool is_sparse_; // The data is stored in sparse byte ranges. 383 bool is_sparse_; // The data is stored in sparse byte ranges.
370 bool range_requested_; // The user requested a byte range. 384 bool range_requested_; // The user requested a byte range.
371 bool handling_206_; // We must deal with this 206 response. 385 bool handling_206_; // We must deal with this 206 response.
372 bool cache_pending_; // We are waiting for the HttpCache. 386 bool cache_pending_; // We are waiting for the HttpCache.
373 bool done_reading_; 387 bool done_reading_;
374 scoped_refptr<IOBuffer> read_buf_; 388 scoped_refptr<IOBuffer> read_buf_;
375 int io_buf_len_; 389 int io_buf_len_;
376 int read_offset_; 390 int read_offset_;
377 int effective_load_flags_; 391 int effective_load_flags_;
378 int write_len_; 392 int write_len_;
379 scoped_ptr<PartialData> partial_; // We are dealing with range requests. 393 scoped_ptr<PartialData> partial_; // We are dealing with range requests.
380 uint64 final_upload_progress_; 394 uint64 final_upload_progress_;
381 base::WeakPtrFactory<Transaction> weak_factory_; 395 base::WeakPtrFactory<Transaction> weak_factory_;
382 CompletionCallback io_callback_; 396 CompletionCallback io_callback_;
397
398 // Members used to track data for histograms.
399 TransactionPattern transaction_pattern_;
400 int bytes_read_from_cache_;
401 int bytes_read_from_network_;
402 base::TimeTicks entry_lock_waiting_since_;
403 base::TimeTicks first_cache_access_since_;
404 base::TimeTicks send_request_since_;
405
383 HttpTransactionDelegate* transaction_delegate_; 406 HttpTransactionDelegate* transaction_delegate_;
384 }; 407 };
385 408
386 } // namespace net 409 } // namespace net
387 410
388 #endif // NET_HTTP_HTTP_CACHE_TRANSACTION_H_ 411 #endif // NET_HTTP_HTTP_CACHE_TRANSACTION_H_
OLDNEW
« no previous file with comments | « net/disk_cache/mem_backend_impl.cc ('k') | net/http/http_cache_transaction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698