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

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

Issue 723343002: Update from https://crrev.com/304121 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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/dns/host_resolver_impl.cc ('k') | net/http/disk_cache_based_quic_server_info.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 #ifndef NET_HTTP_DISK_CACHE_BASED_QUIC_SERVER_INFO_H_ 5 #ifndef NET_HTTP_DISK_CACHE_BASED_QUIC_SERVER_INFO_H_
6 #define NET_HTTP_DISK_CACHE_BASED_QUIC_SERVER_INFO_H_ 6 #define NET_HTTP_DISK_CACHE_BASED_QUIC_SERVER_INFO_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 20 matching lines...) Expand all
31 DiskCacheBasedQuicServerInfo(const QuicServerId& server_id, 31 DiskCacheBasedQuicServerInfo(const QuicServerId& server_id,
32 HttpCache* http_cache); 32 HttpCache* http_cache);
33 33
34 // QuicServerInfo implementation. 34 // QuicServerInfo implementation.
35 void Start() override; 35 void Start() override;
36 int WaitForDataReady(const CompletionCallback& callback) override; 36 int WaitForDataReady(const CompletionCallback& callback) override;
37 void CancelWaitForDataReadyCallback() override; 37 void CancelWaitForDataReadyCallback() override;
38 bool IsDataReady() override; 38 bool IsDataReady() override;
39 bool IsReadyToPersist() override; 39 bool IsReadyToPersist() override;
40 void Persist() override; 40 void Persist() override;
41 void OnExternalCacheHit() override;
41 42
42 private: 43 private:
43 struct CacheOperationDataShim; 44 struct CacheOperationDataShim;
45
44 enum State { 46 enum State {
45 GET_BACKEND, 47 GET_BACKEND,
46 GET_BACKEND_COMPLETE, 48 GET_BACKEND_COMPLETE,
47 OPEN, 49 OPEN,
48 OPEN_COMPLETE, 50 OPEN_COMPLETE,
49 READ, 51 READ,
50 READ_COMPLETE, 52 READ_COMPLETE,
51 WAIT_FOR_DATA_READY_DONE, 53 WAIT_FOR_DATA_READY_DONE,
52 CREATE_OR_OPEN, 54 CREATE_OR_OPEN,
53 CREATE_OR_OPEN_COMPLETE, 55 CREATE_OR_OPEN_COMPLETE,
54 WRITE, 56 WRITE,
55 WRITE_COMPLETE, 57 WRITE_COMPLETE,
56 SET_DONE, 58 SET_DONE,
57 NONE, 59 NONE,
58 }; 60 };
59 61
62 // Enum to track number of times data read/parse/write API calls of
63 // QuicServerInfo to and from disk cache is called.
64 enum QuicServerInfoAPICall {
65 QUIC_SERVER_INFO_START = 0,
66 QUIC_SERVER_INFO_WAIT_FOR_DATA_READY = 1,
67 QUIC_SERVER_INFO_PARSE = 2,
68 QUIC_SERVER_INFO_WAIT_FOR_DATA_READY_CANCEL = 3,
69 QUIC_SERVER_INFO_READY_TO_PERSIST = 4,
70 QUIC_SERVER_INFO_PERSIST = 5,
71 QUIC_SERVER_INFO_EXTERNAL_CACHE_HIT = 6,
72 QUIC_SERVER_INFO_NUM_OF_API_CALLS = 7,
73 };
74
75 // Enum to track failure reasons to read/load/write of QuicServerInfo to
76 // and from disk cache.
77 enum FailureReason {
78 WAIT_FOR_DATA_READY_INVALID_ARGUMENT_FAILURE = 0,
79 GET_BACKEND_FAILURE = 1,
80 OPEN_FAILURE = 2,
81 CREATE_OR_OPEN_FAILURE = 3,
82 PARSE_NO_DATA_FAILURE = 4,
83 PARSE_FAILURE = 5,
84 READ_FAILURE = 6,
85 READY_TO_PERSIST_FAILURE = 7,
86 PERSIST_NO_BACKEND_FAILURE = 8,
87 WRITE_FAILURE = 9,
88 NO_FAILURE = 10,
89 NUM_OF_FAILURES = 11,
90 };
91
60 ~DiskCacheBasedQuicServerInfo() override; 92 ~DiskCacheBasedQuicServerInfo() override;
61 93
94 // Persists |pending_write_data_| if it is not empty, otherwise serializes the
95 // data and pesists it.
96 void PersistInternal();
97
62 std::string key() const; 98 std::string key() const;
63 99
64 // The |unused| parameter is a small hack so that we can have the 100 // The |unused| parameter is a small hack so that we can have the
65 // CacheOperationDataShim object owned by the Callback that is created for 101 // CacheOperationDataShim object owned by the Callback that is created for
66 // this method. See comment above CacheOperationDataShim for details. 102 // this method. See comment above CacheOperationDataShim for details.
67 void OnIOComplete(CacheOperationDataShim* unused, int rv); 103 void OnIOComplete(CacheOperationDataShim* unused, int rv);
68 104
69 int DoLoop(int rv); 105 int DoLoop(int rv);
70 106
71 int DoGetBackendComplete(int rv); 107 int DoGetBackendComplete(int rv);
72 int DoOpenComplete(int rv); 108 int DoOpenComplete(int rv);
73 int DoReadComplete(int rv); 109 int DoReadComplete(int rv);
74 int DoWriteComplete(int rv); 110 int DoWriteComplete(int rv);
75 int DoCreateOrOpenComplete(int rv); 111 int DoCreateOrOpenComplete(int rv);
76 112
77 int DoGetBackend(); 113 int DoGetBackend();
78 int DoOpen(); 114 int DoOpen();
79 int DoRead(); 115 int DoRead();
80 int DoWrite(); 116 int DoWrite();
81 int DoCreateOrOpen(); 117 int DoCreateOrOpen();
82 118
83 // DoWaitForDataReadyDone is the terminal state of the read operation. 119 // DoWaitForDataReadyDone is the terminal state of the read operation.
84 int DoWaitForDataReadyDone(); 120 int DoWaitForDataReadyDone();
85 121
86 // DoSetDone is the terminal state of the write operation. 122 // DoSetDone is the terminal state of the write operation.
87 int DoSetDone(); 123 int DoSetDone();
88 124
125 // Tracks in a histogram the number of times data read/parse/write API calls
126 // of QuicServerInfo to and from disk cache is called.
127 void RecordQuicServerInfoStatus(QuicServerInfoAPICall call);
128
129 // Tracks in a histogram the failure reasons to read/load/write of
130 // QuicServerInfo to and from disk cache. It also saves the |failure| in
131 // |last_failure_|.
132 void RecordQuicServerInfoFailure(FailureReason failure);
133
134 // Tracks in a histogram if |last_failure_| is not NO_FAILURE.
135 void RecordLastFailure();
136
89 CacheOperationDataShim* data_shim_; // Owned by |io_callback_|. 137 CacheOperationDataShim* data_shim_; // Owned by |io_callback_|.
90 CompletionCallback io_callback_; 138 CompletionCallback io_callback_;
91 State state_; 139 State state_;
92 bool ready_; 140 bool ready_;
93 bool found_entry_; // Controls the behavior of DoCreateOrOpen. 141 bool found_entry_; // Controls the behavior of DoCreateOrOpen.
94 std::string new_data_; 142 std::string new_data_;
143 std::string pending_write_data_;
95 const QuicServerId server_id_; 144 const QuicServerId server_id_;
96 HttpCache* const http_cache_; 145 HttpCache* const http_cache_;
97 disk_cache::Backend* backend_; 146 disk_cache::Backend* backend_;
98 disk_cache::Entry* entry_; 147 disk_cache::Entry* entry_;
99 CompletionCallback user_callback_; 148 CompletionCallback wait_for_ready_callback_;
100 scoped_refptr<IOBuffer> read_buffer_; 149 scoped_refptr<IOBuffer> read_buffer_;
101 scoped_refptr<IOBuffer> write_buffer_; 150 scoped_refptr<IOBuffer> write_buffer_;
102 std::string data_; 151 std::string data_;
103 base::TimeTicks load_start_time_; 152 base::TimeTicks load_start_time_;
153 FailureReason last_failure_;
104 154
105 base::WeakPtrFactory<DiskCacheBasedQuicServerInfo> weak_factory_; 155 base::WeakPtrFactory<DiskCacheBasedQuicServerInfo> weak_factory_;
156
157 DISALLOW_COPY_AND_ASSIGN(DiskCacheBasedQuicServerInfo);
106 }; 158 };
107 159
108 } // namespace net 160 } // namespace net
109 161
110 #endif // NET_HTTP_DISK_CACHE_BASED_QUIC_SERVER_INFO_H_ 162 #endif // NET_HTTP_DISK_CACHE_BASED_QUIC_SERVER_INFO_H_
OLDNEW
« no previous file with comments | « net/dns/host_resolver_impl.cc ('k') | net/http/disk_cache_based_quic_server_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698