1*6777b538SAndroid Build Coastguard Worker // Copyright 2017 The Chromium Authors 2*6777b538SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be 3*6777b538SAndroid Build Coastguard Worker // found in the LICENSE file. 4*6777b538SAndroid Build Coastguard Worker 5*6777b538SAndroid Build Coastguard Worker #ifndef NET_HTTP_HTTP_CACHE_WRITERS_H_ 6*6777b538SAndroid Build Coastguard Worker #define NET_HTTP_HTTP_CACHE_WRITERS_H_ 7*6777b538SAndroid Build Coastguard Worker 8*6777b538SAndroid Build Coastguard Worker #include <map> 9*6777b538SAndroid Build Coastguard Worker #include <memory> 10*6777b538SAndroid Build Coastguard Worker 11*6777b538SAndroid Build Coastguard Worker #include "base/memory/raw_ptr.h" 12*6777b538SAndroid Build Coastguard Worker #include "base/memory/weak_ptr.h" 13*6777b538SAndroid Build Coastguard Worker #include "net/base/completion_once_callback.h" 14*6777b538SAndroid Build Coastguard Worker #include "net/http/http_cache.h" 15*6777b538SAndroid Build Coastguard Worker #include "net/http/http_response_info.h" 16*6777b538SAndroid Build Coastguard Worker 17*6777b538SAndroid Build Coastguard Worker namespace net { 18*6777b538SAndroid Build Coastguard Worker 19*6777b538SAndroid Build Coastguard Worker class HttpResponseInfo; 20*6777b538SAndroid Build Coastguard Worker class IOBuffer; 21*6777b538SAndroid Build Coastguard Worker class PartialData; 22*6777b538SAndroid Build Coastguard Worker 23*6777b538SAndroid Build Coastguard Worker // If multiple HttpCache::Transactions are accessing the same cache entry 24*6777b538SAndroid Build Coastguard Worker // simultaneously, their access to the data read from network is synchronized 25*6777b538SAndroid Build Coastguard Worker // by HttpCache::Writers. This enables each of those transactions to drive 26*6777b538SAndroid Build Coastguard Worker // reading the response body from the network ensuring a slow consumer does not 27*6777b538SAndroid Build Coastguard Worker // starve other consumers of the same resource. 28*6777b538SAndroid Build Coastguard Worker // 29*6777b538SAndroid Build Coastguard Worker // Writers represents the set of all HttpCache::Transactions that are reading 30*6777b538SAndroid Build Coastguard Worker // from the network using the same network transaction and writing to the same 31*6777b538SAndroid Build Coastguard Worker // cache entry. It is owned by the ActiveEntry. The writers object must be 32*6777b538SAndroid Build Coastguard Worker // deleted when HttpCache::WritersDoneWritingToEntry is called as it doesn't 33*6777b538SAndroid Build Coastguard Worker // expect any of its ongoing IO transactions (e.g., network reads or cache 34*6777b538SAndroid Build Coastguard Worker // writers) to complete after that point and won't know what to do with them. 35*6777b538SAndroid Build Coastguard Worker class NET_EXPORT_PRIVATE HttpCache::Writers { 36*6777b538SAndroid Build Coastguard Worker public: 37*6777b538SAndroid Build Coastguard Worker // This is the information maintained by Writers in the context of each 38*6777b538SAndroid Build Coastguard Worker // transaction. 39*6777b538SAndroid Build Coastguard Worker // |partial| is owned by the transaction and to be sure there are no 40*6777b538SAndroid Build Coastguard Worker // dangling pointers, it must be ensured that transaction's reference and 41*6777b538SAndroid Build Coastguard Worker // this information will be removed from writers once the transaction is 42*6777b538SAndroid Build Coastguard Worker // deleted. 43*6777b538SAndroid Build Coastguard Worker struct NET_EXPORT_PRIVATE TransactionInfo { 44*6777b538SAndroid Build Coastguard Worker TransactionInfo(PartialData* partial, 45*6777b538SAndroid Build Coastguard Worker bool truncated, 46*6777b538SAndroid Build Coastguard Worker HttpResponseInfo info); 47*6777b538SAndroid Build Coastguard Worker ~TransactionInfo(); 48*6777b538SAndroid Build Coastguard Worker TransactionInfo& operator=(const TransactionInfo&); 49*6777b538SAndroid Build Coastguard Worker TransactionInfo(const TransactionInfo&); 50*6777b538SAndroid Build Coastguard Worker 51*6777b538SAndroid Build Coastguard Worker raw_ptr<PartialData> partial; 52*6777b538SAndroid Build Coastguard Worker bool truncated; 53*6777b538SAndroid Build Coastguard Worker HttpResponseInfo response_info; 54*6777b538SAndroid Build Coastguard Worker }; 55*6777b538SAndroid Build Coastguard Worker 56*6777b538SAndroid Build Coastguard Worker // |cache| and |entry| must outlive this object. 57*6777b538SAndroid Build Coastguard Worker Writers(HttpCache* cache, scoped_refptr<HttpCache::ActiveEntry> entry); 58*6777b538SAndroid Build Coastguard Worker 59*6777b538SAndroid Build Coastguard Worker Writers(const Writers&) = delete; 60*6777b538SAndroid Build Coastguard Worker Writers& operator=(const Writers&) = delete; 61*6777b538SAndroid Build Coastguard Worker 62*6777b538SAndroid Build Coastguard Worker ~Writers(); 63*6777b538SAndroid Build Coastguard Worker 64*6777b538SAndroid Build Coastguard Worker // Retrieves data from the network transaction associated with the Writers 65*6777b538SAndroid Build Coastguard Worker // object. This may be done directly (via a network read into |*buf->data()|) 66*6777b538SAndroid Build Coastguard Worker // or indirectly (by copying from another transactions buffer into 67*6777b538SAndroid Build Coastguard Worker // |*buf->data()| on network read completion) depending on whether or not a 68*6777b538SAndroid Build Coastguard Worker // read is currently in progress. May return the result synchronously or 69*6777b538SAndroid Build Coastguard Worker // return ERR_IO_PENDING: if ERR_IO_PENDING is returned, |callback| will be 70*6777b538SAndroid Build Coastguard Worker // run to inform the consumer of the result of the Read(). 71*6777b538SAndroid Build Coastguard Worker // |transaction| may be removed while Read() is ongoing. In that case Writers 72*6777b538SAndroid Build Coastguard Worker // will still complete the Read() processing but will not invoke the 73*6777b538SAndroid Build Coastguard Worker // |callback|. 74*6777b538SAndroid Build Coastguard Worker int Read(scoped_refptr<IOBuffer> buf, 75*6777b538SAndroid Build Coastguard Worker int buf_len, 76*6777b538SAndroid Build Coastguard Worker CompletionOnceCallback callback, 77*6777b538SAndroid Build Coastguard Worker Transaction* transaction); 78*6777b538SAndroid Build Coastguard Worker 79*6777b538SAndroid Build Coastguard Worker // Invoked when StopCaching is called on a member transaction. 80*6777b538SAndroid Build Coastguard Worker // It stops caching only if there are no other transactions. Returns true if 81*6777b538SAndroid Build Coastguard Worker // caching can be stopped. 82*6777b538SAndroid Build Coastguard Worker // |keep_entry| should be true if the entry needs to be preserved after 83*6777b538SAndroid Build Coastguard Worker // truncation. 84*6777b538SAndroid Build Coastguard Worker bool StopCaching(bool keep_entry); 85*6777b538SAndroid Build Coastguard Worker 86*6777b538SAndroid Build Coastguard Worker // Membership functions like AddTransaction and RemoveTransaction are invoked 87*6777b538SAndroid Build Coastguard Worker // by HttpCache on behalf of the HttpCache::Transaction. 88*6777b538SAndroid Build Coastguard Worker 89*6777b538SAndroid Build Coastguard Worker // Adds an HttpCache::Transaction to Writers. 90*6777b538SAndroid Build Coastguard Worker // Should only be invoked if CanAddWriters() returns true. 91*6777b538SAndroid Build Coastguard Worker // |parallel_writing_pattern| governs whether writing is an exclusive 92*6777b538SAndroid Build Coastguard Worker // operation implying that Writers can contain at most one transaction till 93*6777b538SAndroid Build Coastguard Worker // the completion of the response body. It is illegal to invoke with 94*6777b538SAndroid Build Coastguard Worker // |parallel_writing_pattern| as PARALLEL_WRITING_NOT_JOIN* if there is 95*6777b538SAndroid Build Coastguard Worker // already a transaction present. 96*6777b538SAndroid Build Coastguard Worker // |transaction| can be destroyed at any point and it should invoke 97*6777b538SAndroid Build Coastguard Worker // HttpCache::DoneWithEntry() during its destruction. This will also ensure 98*6777b538SAndroid Build Coastguard Worker // any pointers in |info| are not accessed after the transaction is destroyed. 99*6777b538SAndroid Build Coastguard Worker void AddTransaction(Transaction* transaction, 100*6777b538SAndroid Build Coastguard Worker ParallelWritingPattern initial_writing_pattern, 101*6777b538SAndroid Build Coastguard Worker RequestPriority priority, 102*6777b538SAndroid Build Coastguard Worker const TransactionInfo& info); 103*6777b538SAndroid Build Coastguard Worker 104*6777b538SAndroid Build Coastguard Worker // Invoked when the transaction is done working with the entry. 105*6777b538SAndroid Build Coastguard Worker void RemoveTransaction(Transaction* transaction, bool success); 106*6777b538SAndroid Build Coastguard Worker 107*6777b538SAndroid Build Coastguard Worker // Invoked when there is a change in a member transaction's priority or a 108*6777b538SAndroid Build Coastguard Worker // member transaction is removed. 109*6777b538SAndroid Build Coastguard Worker void UpdatePriority(); 110*6777b538SAndroid Build Coastguard Worker 111*6777b538SAndroid Build Coastguard Worker // Returns true if this object is empty. IsEmpty()112*6777b538SAndroid Build Coastguard Worker bool IsEmpty() const { return all_writers_.empty(); } 113*6777b538SAndroid Build Coastguard Worker 114*6777b538SAndroid Build Coastguard Worker // Returns true if |transaction| is part of writers. HasTransaction(const Transaction * transaction)115*6777b538SAndroid Build Coastguard Worker bool HasTransaction(const Transaction* transaction) const { 116*6777b538SAndroid Build Coastguard Worker return all_writers_.count(const_cast<Transaction*>(transaction)) > 0; 117*6777b538SAndroid Build Coastguard Worker } 118*6777b538SAndroid Build Coastguard Worker 119*6777b538SAndroid Build Coastguard Worker // Returns true if more writers can be added for shared writing. Also fills in 120*6777b538SAndroid Build Coastguard Worker // the |reason| for why a transaction cannot be added. 121*6777b538SAndroid Build Coastguard Worker bool CanAddWriters(ParallelWritingPattern* reason); 122*6777b538SAndroid Build Coastguard Worker 123*6777b538SAndroid Build Coastguard Worker // Returns if only one transaction can be a member of writers. IsExclusive()124*6777b538SAndroid Build Coastguard Worker bool IsExclusive() const { return is_exclusive_; } 125*6777b538SAndroid Build Coastguard Worker 126*6777b538SAndroid Build Coastguard Worker // Returns the network transaction which may be nullptr for range requests. network_transaction()127*6777b538SAndroid Build Coastguard Worker const HttpTransaction* network_transaction() const { 128*6777b538SAndroid Build Coastguard Worker return network_transaction_.get(); 129*6777b538SAndroid Build Coastguard Worker } 130*6777b538SAndroid Build Coastguard Worker 131*6777b538SAndroid Build Coastguard Worker void CloseConnectionOnDestruction(); 132*6777b538SAndroid Build Coastguard Worker 133*6777b538SAndroid Build Coastguard Worker // Returns the load state of the |network_transaction_| if present else 134*6777b538SAndroid Build Coastguard Worker // returns LOAD_STATE_IDLE. 135*6777b538SAndroid Build Coastguard Worker LoadState GetLoadState() const; 136*6777b538SAndroid Build Coastguard Worker 137*6777b538SAndroid Build Coastguard Worker // Sets the network transaction argument to |network_transaction_|. Must be 138*6777b538SAndroid Build Coastguard Worker // invoked before Read can be invoked. 139*6777b538SAndroid Build Coastguard Worker void SetNetworkTransaction( 140*6777b538SAndroid Build Coastguard Worker Transaction* transaction, 141*6777b538SAndroid Build Coastguard Worker std::unique_ptr<HttpTransaction> network_transaction); 142*6777b538SAndroid Build Coastguard Worker 143*6777b538SAndroid Build Coastguard Worker // Resets the network transaction to nullptr. Required for range requests as 144*6777b538SAndroid Build Coastguard Worker // they might use the current network transaction only for part of the 145*6777b538SAndroid Build Coastguard Worker // request. Must only be invoked for range requests. 146*6777b538SAndroid Build Coastguard Worker void ResetNetworkTransaction(); 147*6777b538SAndroid Build Coastguard Worker 148*6777b538SAndroid Build Coastguard Worker // Returns if response is only being read from the network. network_read_only()149*6777b538SAndroid Build Coastguard Worker bool network_read_only() const { return network_read_only_; } 150*6777b538SAndroid Build Coastguard Worker GetTransactionsCount()151*6777b538SAndroid Build Coastguard Worker int GetTransactionsCount() const { return all_writers_.size(); } 152*6777b538SAndroid Build Coastguard Worker 153*6777b538SAndroid Build Coastguard Worker private: 154*6777b538SAndroid Build Coastguard Worker friend class WritersTest; 155*6777b538SAndroid Build Coastguard Worker 156*6777b538SAndroid Build Coastguard Worker enum class State { 157*6777b538SAndroid Build Coastguard Worker UNSET, 158*6777b538SAndroid Build Coastguard Worker NONE, 159*6777b538SAndroid Build Coastguard Worker NETWORK_READ, 160*6777b538SAndroid Build Coastguard Worker NETWORK_READ_COMPLETE, 161*6777b538SAndroid Build Coastguard Worker CACHE_WRITE_DATA, 162*6777b538SAndroid Build Coastguard Worker CACHE_WRITE_DATA_COMPLETE, 163*6777b538SAndroid Build Coastguard Worker }; 164*6777b538SAndroid Build Coastguard Worker 165*6777b538SAndroid Build Coastguard Worker // These transactions are waiting on Read. After the active transaction 166*6777b538SAndroid Build Coastguard Worker // completes writing the data to the cache, their buffer would be filled with 167*6777b538SAndroid Build Coastguard Worker // the data and their callback will be invoked. 168*6777b538SAndroid Build Coastguard Worker struct WaitingForRead { 169*6777b538SAndroid Build Coastguard Worker scoped_refptr<IOBuffer> read_buf; 170*6777b538SAndroid Build Coastguard Worker int read_buf_len; 171*6777b538SAndroid Build Coastguard Worker int write_len = 0; 172*6777b538SAndroid Build Coastguard Worker CompletionOnceCallback callback; 173*6777b538SAndroid Build Coastguard Worker WaitingForRead(scoped_refptr<IOBuffer> read_buf, 174*6777b538SAndroid Build Coastguard Worker int len, 175*6777b538SAndroid Build Coastguard Worker CompletionOnceCallback consumer_callback); 176*6777b538SAndroid Build Coastguard Worker ~WaitingForRead(); 177*6777b538SAndroid Build Coastguard Worker WaitingForRead(WaitingForRead&&); 178*6777b538SAndroid Build Coastguard Worker }; 179*6777b538SAndroid Build Coastguard Worker using WaitingForReadMap = std::map<Transaction*, WaitingForRead>; 180*6777b538SAndroid Build Coastguard Worker 181*6777b538SAndroid Build Coastguard Worker using TransactionMap = std::map<Transaction*, TransactionInfo>; 182*6777b538SAndroid Build Coastguard Worker 183*6777b538SAndroid Build Coastguard Worker // Runs the state transition loop. Resets and calls |callback_| on exit, 184*6777b538SAndroid Build Coastguard Worker // unless the return value is ERR_IO_PENDING. 185*6777b538SAndroid Build Coastguard Worker int DoLoop(int result); 186*6777b538SAndroid Build Coastguard Worker 187*6777b538SAndroid Build Coastguard Worker // State machine functions. 188*6777b538SAndroid Build Coastguard Worker int DoNetworkRead(); 189*6777b538SAndroid Build Coastguard Worker int DoNetworkReadComplete(int result); 190*6777b538SAndroid Build Coastguard Worker int DoCacheWriteData(int num_bytes); 191*6777b538SAndroid Build Coastguard Worker int DoCacheWriteDataComplete(int result); 192*6777b538SAndroid Build Coastguard Worker 193*6777b538SAndroid Build Coastguard Worker // Helper functions for callback. 194*6777b538SAndroid Build Coastguard Worker void OnNetworkReadFailure(int result); 195*6777b538SAndroid Build Coastguard Worker void OnCacheWriteFailure(); 196*6777b538SAndroid Build Coastguard Worker void OnDataReceived(int result); 197*6777b538SAndroid Build Coastguard Worker 198*6777b538SAndroid Build Coastguard Worker // Completes any pending IO_PENDING read operations by copying any received 199*6777b538SAndroid Build Coastguard Worker // bytes from read_buf_ to the given buffer and posts a task to run the 200*6777b538SAndroid Build Coastguard Worker // callback with |result|. 201*6777b538SAndroid Build Coastguard Worker void CompleteWaitingForReadTransactions(int result); 202*6777b538SAndroid Build Coastguard Worker 203*6777b538SAndroid Build Coastguard Worker // Removes idle writers, passing |result| which is to be used for any 204*6777b538SAndroid Build Coastguard Worker // subsequent read transaction. 205*6777b538SAndroid Build Coastguard Worker void RemoveIdleWriters(int result); 206*6777b538SAndroid Build Coastguard Worker 207*6777b538SAndroid Build Coastguard Worker // Invoked when |active_transaction_| fails to read from network or write to 208*6777b538SAndroid Build Coastguard Worker // cache. |error| indicates network read error code or cache write error. 209*6777b538SAndroid Build Coastguard Worker void ProcessFailure(int error); 210*6777b538SAndroid Build Coastguard Worker 211*6777b538SAndroid Build Coastguard Worker // Returns true if |this| only contains idle writers. Idle writers are those 212*6777b538SAndroid Build Coastguard Worker // that are waiting for Read to be invoked by the consumer. 213*6777b538SAndroid Build Coastguard Worker bool ContainsOnlyIdleWriters() const; 214*6777b538SAndroid Build Coastguard Worker 215*6777b538SAndroid Build Coastguard Worker // Returns true if its worth marking the entry as truncated. 216*6777b538SAndroid Build Coastguard Worker // TODO(shivanisha): Refactor this so that it could be const. 217*6777b538SAndroid Build Coastguard Worker bool ShouldTruncate(); 218*6777b538SAndroid Build Coastguard Worker 219*6777b538SAndroid Build Coastguard Worker // Enqueues a truncation operation to the entry. Ignores the response. 220*6777b538SAndroid Build Coastguard Worker void TruncateEntry(); 221*6777b538SAndroid Build Coastguard Worker 222*6777b538SAndroid Build Coastguard Worker // Remove the transaction. 223*6777b538SAndroid Build Coastguard Worker void EraseTransaction(Transaction* transaction, int result); 224*6777b538SAndroid Build Coastguard Worker TransactionMap::iterator EraseTransaction(TransactionMap::iterator it, 225*6777b538SAndroid Build Coastguard Worker int result); 226*6777b538SAndroid Build Coastguard Worker void SetCacheCallback(bool success, const TransactionSet& make_readers); 227*6777b538SAndroid Build Coastguard Worker 228*6777b538SAndroid Build Coastguard Worker // IO Completion callback function. 229*6777b538SAndroid Build Coastguard Worker void OnIOComplete(int result); 230*6777b538SAndroid Build Coastguard Worker 231*6777b538SAndroid Build Coastguard Worker State next_state_ = State::NONE; 232*6777b538SAndroid Build Coastguard Worker 233*6777b538SAndroid Build Coastguard Worker // True if only reading from network and not writing to cache. 234*6777b538SAndroid Build Coastguard Worker bool network_read_only_ = false; 235*6777b538SAndroid Build Coastguard Worker 236*6777b538SAndroid Build Coastguard Worker raw_ptr<HttpCache> const cache_ = nullptr; 237*6777b538SAndroid Build Coastguard Worker 238*6777b538SAndroid Build Coastguard Worker // Owner of |this|. 239*6777b538SAndroid Build Coastguard Worker scoped_refptr<HttpCache::ActiveEntry> entry_; 240*6777b538SAndroid Build Coastguard Worker 241*6777b538SAndroid Build Coastguard Worker std::unique_ptr<HttpTransaction> network_transaction_; 242*6777b538SAndroid Build Coastguard Worker 243*6777b538SAndroid Build Coastguard Worker scoped_refptr<IOBuffer> read_buf_; 244*6777b538SAndroid Build Coastguard Worker 245*6777b538SAndroid Build Coastguard Worker int io_buf_len_ = 0; 246*6777b538SAndroid Build Coastguard Worker int write_len_ = 0; 247*6777b538SAndroid Build Coastguard Worker 248*6777b538SAndroid Build Coastguard Worker // The cache transaction that is the current consumer of network_transaction_ 249*6777b538SAndroid Build Coastguard Worker // ::Read or writing to the entry and is waiting for the operation to be 250*6777b538SAndroid Build Coastguard Worker // completed. This is used to ensure there is at most one consumer of 251*6777b538SAndroid Build Coastguard Worker // network_transaction_ at a time. 252*6777b538SAndroid Build Coastguard Worker raw_ptr<Transaction> active_transaction_ = nullptr; 253*6777b538SAndroid Build Coastguard Worker 254*6777b538SAndroid Build Coastguard Worker // Transactions whose consumers have invoked Read, but another transaction is 255*6777b538SAndroid Build Coastguard Worker // currently the |active_transaction_|. After the network read and cache write 256*6777b538SAndroid Build Coastguard Worker // is complete, the waiting transactions will be notified. 257*6777b538SAndroid Build Coastguard Worker WaitingForReadMap waiting_for_read_; 258*6777b538SAndroid Build Coastguard Worker 259*6777b538SAndroid Build Coastguard Worker // Includes all transactions. ResetStateForEmptyWriters should be invoked 260*6777b538SAndroid Build Coastguard Worker // whenever all_writers_ becomes empty. 261*6777b538SAndroid Build Coastguard Worker TransactionMap all_writers_; 262*6777b538SAndroid Build Coastguard Worker 263*6777b538SAndroid Build Coastguard Worker // True if multiple transactions are not allowed e.g. for partial requests. 264*6777b538SAndroid Build Coastguard Worker bool is_exclusive_ = false; 265*6777b538SAndroid Build Coastguard Worker ParallelWritingPattern parallel_writing_pattern_ = PARALLEL_WRITING_NONE; 266*6777b538SAndroid Build Coastguard Worker 267*6777b538SAndroid Build Coastguard Worker // Current priority of the request. It is always the maximum of all the writer 268*6777b538SAndroid Build Coastguard Worker // transactions. 269*6777b538SAndroid Build Coastguard Worker RequestPriority priority_ = MINIMUM_PRIORITY; 270*6777b538SAndroid Build Coastguard Worker 271*6777b538SAndroid Build Coastguard Worker // Response info of the most recent transaction added to Writers will be used 272*6777b538SAndroid Build Coastguard Worker // to write back the headers along with the truncated bit set. This is done so 273*6777b538SAndroid Build Coastguard Worker // that we don't overwrite headers written by a more recent transaction with 274*6777b538SAndroid Build Coastguard Worker // older headers while truncating. 275*6777b538SAndroid Build Coastguard Worker HttpResponseInfo response_info_truncation_; 276*6777b538SAndroid Build Coastguard Worker 277*6777b538SAndroid Build Coastguard Worker // Do not mark a partial request as truncated if it is not already a truncated 278*6777b538SAndroid Build Coastguard Worker // entry to start with. 279*6777b538SAndroid Build Coastguard Worker bool partial_do_not_truncate_ = false; 280*6777b538SAndroid Build Coastguard Worker 281*6777b538SAndroid Build Coastguard Worker // True if the entry should be kept, even if the response was not completely 282*6777b538SAndroid Build Coastguard Worker // written. 283*6777b538SAndroid Build Coastguard Worker bool should_keep_entry_ = true; 284*6777b538SAndroid Build Coastguard Worker 285*6777b538SAndroid Build Coastguard Worker // The latest time `this` starts writing data to the disk cache. 286*6777b538SAndroid Build Coastguard Worker base::TimeTicks last_disk_cache_access_start_time_; 287*6777b538SAndroid Build Coastguard Worker 288*6777b538SAndroid Build Coastguard Worker CompletionOnceCallback callback_; // Callback for active_transaction_. 289*6777b538SAndroid Build Coastguard Worker 290*6777b538SAndroid Build Coastguard Worker // Since cache_ can destroy |this|, |cache_callback_| is only invoked at the 291*6777b538SAndroid Build Coastguard Worker // end of DoLoop(). 292*6777b538SAndroid Build Coastguard Worker base::OnceClosure cache_callback_; // Callback for cache_. 293*6777b538SAndroid Build Coastguard Worker 294*6777b538SAndroid Build Coastguard Worker base::WeakPtrFactory<Writers> weak_factory_{this}; 295*6777b538SAndroid Build Coastguard Worker }; 296*6777b538SAndroid Build Coastguard Worker 297*6777b538SAndroid Build Coastguard Worker } // namespace net 298*6777b538SAndroid Build Coastguard Worker 299*6777b538SAndroid Build Coastguard Worker #endif // NET_HTTP_HTTP_CACHE_WRITERS_H_ 300