Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef NET_HTTP_CACHE_LOOKUP_MANAGER_H_ | |
| 6 #define NET_HTTP_CACHE_LOOKUP_MANAGER_H_ | |
| 7 | |
| 8 #include "net/base/net_export.h" | |
| 9 #include "net/http/http_cache.h" | |
| 10 #include "net/http/http_cache_transaction.h" | |
| 11 #include "net/spdy/server_push_delegate.h" | |
| 12 | |
| 13 namespace net { | |
| 14 | |
| 15 // An implementation of ServerPushDelegate that issues an HttpCache::Transaction | |
| 16 // to lookup whether the response to the pushed URL is cached and cancel the | |
| 17 // push in that case. | |
| 18 class NET_EXPORT_PRIVATE HttpCacheLookupManager : public ServerPushDelegate { | |
| 19 public: | |
| 20 // |http_cache| MUST outlive the HttpCacheLookupManager. | |
| 21 HttpCacheLookupManager(HttpCache* http_cache, | |
| 22 const NetLogWithSource& net_log); | |
| 23 ~HttpCacheLookupManager() override; | |
| 24 | |
| 25 void OnPush(std::unique_ptr<ServerPushHelper> push_helper) override; | |
| 26 | |
| 27 // Invoked when the HttpCache::Transaction for |url| finishes to cancel the | |
| 28 // server push if the response to the server push is found cached. | |
| 29 void OnLookupComplete(const GURL& url, int rv); | |
| 30 | |
| 31 private: | |
| 32 // A class that takes the ownership of ServerPushHelper and issues and owns an | |
|
Zhongyi Shi
2016/11/18 20:34:19
The comment has been updated in next PS
// // A cl
| |
| 33 // HttpCache::Transaction which lookups the response in cache for the server | |
| 34 // push. | |
| 35 class LookupTransaction { | |
| 36 public: | |
| 37 LookupTransaction(std::unique_ptr<ServerPushHelper> push_helper); | |
| 38 ~LookupTransaction(); | |
| 39 | |
| 40 // Issues an HttpCache::Transaction to lookup whether the response is cached | |
| 41 // without header validation. | |
| 42 int StartLookup(HttpCache* cache, | |
| 43 const CompletionCallback& callback, | |
| 44 const NetLogWithSource& net_log); | |
| 45 | |
| 46 void CancelPush(); | |
| 47 | |
| 48 private: | |
| 49 std::unique_ptr<ServerPushHelper> push_helper; | |
| 50 std::unique_ptr<HttpRequestInfo> request; | |
| 51 std::unique_ptr<HttpTransaction> transaction; | |
| 52 }; | |
| 53 | |
| 54 NetLogWithSource net_log_; | |
| 55 // HttpCache must outlive the HttpCacheLookupManager. | |
| 56 HttpCache* http_cache_; | |
| 57 std::map<GURL, std::unique_ptr<LookupTransaction>> lookup_transactions_; | |
| 58 base::WeakPtrFactory<HttpCacheLookupManager> weak_factory_; | |
| 59 }; | |
| 60 | |
| 61 } // namespace net | |
| 62 | |
| 63 #endif // NET_HTTP_CACHE_LOOKUP_MANAGER_H_ | |
| OLD | NEW |