OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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_HTTP_CACHE_LOOKUP_MANAGER_H_ | 5 #ifndef NET_HTTP_HTTP_CACHE_LOOKUP_MANAGER_H_ |
6 #define NET_HTTP_HTTP_CACHE_LOOKUP_MANAGER_H_ | 6 #define NET_HTTP_HTTP_CACHE_LOOKUP_MANAGER_H_ |
7 | 7 |
8 #include "net/base/net_export.h" | 8 #include "net/base/net_export.h" |
9 #include "net/http/http_cache.h" | 9 #include "net/http/http_cache.h" |
10 #include "net/http/http_cache_transaction.h" | 10 #include "net/http/http_cache_transaction.h" |
11 #include "net/spdy/server_push_delegate.h" | 11 #include "net/spdy/server_push_delegate.h" |
12 | 12 |
13 namespace net { | 13 namespace net { |
14 | 14 |
15 // An implementation of ServerPushDelegate that issues an HttpCache::Transaction | 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 | 16 // to lookup whether the response to the pushed URL is cached and cancel the |
17 // push in that case. | 17 // push in that case. |
18 class NET_EXPORT_PRIVATE HttpCacheLookupManager : public ServerPushDelegate { | 18 class NET_EXPORT_PRIVATE HttpCacheLookupManager : public ServerPushDelegate { |
19 public: | 19 public: |
20 // |http_cache| MUST outlive the HttpCacheLookupManager. | 20 // |http_cache| MUST outlive the HttpCacheLookupManager. |
21 HttpCacheLookupManager(HttpCache* http_cache, | 21 HttpCacheLookupManager(HttpCache* http_cache, NetLog* net_log); |
eroman
2017/02/10 23:57:47
I don't believe this |net_log| parameter is needed
Zhongyi Shi
2017/02/11 02:21:11
Done.
| |
22 const NetLogWithSource& net_log); | |
23 ~HttpCacheLookupManager() override; | 22 ~HttpCacheLookupManager() override; |
24 | 23 |
25 void OnPush(std::unique_ptr<ServerPushHelper> push_helper) override; | 24 // ServerPushDelegate implementation. |
25 // |source_net_log| is owned by the caller of this method. | |
eroman
2017/02/10 23:57:47
Can you re-phrase the comment a bit? "owned" doesn
Zhongyi Shi
2017/02/11 02:21:10
Yup, this will always be called from a session: ei
| |
26 void OnPush(std::unique_ptr<ServerPushHelper> push_helper, | |
27 const NetLogWithSource& source_net_log) override; | |
26 | 28 |
27 // Invoked when the HttpCache::Transaction for |url| finishes to cancel the | 29 // Invoked when the HttpCache::Transaction for |url| finishes to cancel the |
28 // server push if the response to the server push is found cached. | 30 // server push if the response to the server push is found cached. |
29 void OnLookupComplete(const GURL& url, int rv); | 31 void OnLookupComplete(const GURL& url, int rv); |
30 | 32 |
31 private: | 33 private: |
32 // A class that takes the ownership of ServerPushHelper, issues and owns an | 34 // A class that takes the ownership of ServerPushHelper, issues and owns an |
33 // HttpCache::Transaction which lookups the response in cache for the server | 35 // HttpCache::Transaction which lookups the response in cache for the server |
34 // push. | 36 // push. |
35 class LookupTransaction { | 37 class LookupTransaction { |
36 public: | 38 public: |
37 LookupTransaction(std::unique_ptr<ServerPushHelper> push_helper); | 39 LookupTransaction(std::unique_ptr<ServerPushHelper> push_helper, |
40 NetLog* net_log); | |
38 ~LookupTransaction(); | 41 ~LookupTransaction(); |
39 | 42 |
40 // Issues an HttpCache::Transaction to lookup whether the response is cached | 43 // Issues an HttpCache::Transaction to lookup whether the response is cached |
41 // without header validation. | 44 // without header validation. |
45 // |source_net_log| is owned by the requester of server push cache lookup. | |
eroman
2017/02/10 23:57:47
Same comment as earlier regarding comment + parame
Zhongyi Shi
2017/02/11 02:21:10
Done.
| |
42 int StartLookup(HttpCache* cache, | 46 int StartLookup(HttpCache* cache, |
43 const CompletionCallback& callback, | 47 const CompletionCallback& callback, |
44 const NetLogWithSource& net_log); | 48 const NetLogWithSource& source_net_log); |
45 | 49 |
46 void CancelPush(); | 50 void OnLookupComplete(bool found_in_cache); |
47 | 51 |
48 private: | 52 private: |
49 std::unique_ptr<ServerPushHelper> push_helper_; | 53 std::unique_ptr<ServerPushHelper> push_helper_; |
50 std::unique_ptr<HttpRequestInfo> request_; | 54 std::unique_ptr<HttpRequestInfo> request_; |
51 std::unique_ptr<HttpTransaction> transaction_; | 55 std::unique_ptr<HttpTransaction> transaction_; |
56 const NetLogWithSource net_log_; | |
52 }; | 57 }; |
53 | 58 |
54 NetLogWithSource net_log_; | 59 NetLog* net_log_; |
eroman
2017/02/10 23:57:47
Per comment above, I believe we delete this.
Zhongyi Shi
2017/02/11 02:21:10
Done.
| |
55 // HttpCache must outlive the HttpCacheLookupManager. | 60 // HttpCache must outlive the HttpCacheLookupManager. |
56 HttpCache* http_cache_; | 61 HttpCache* http_cache_; |
57 std::map<GURL, std::unique_ptr<LookupTransaction>> lookup_transactions_; | 62 std::map<GURL, std::unique_ptr<LookupTransaction>> lookup_transactions_; |
58 base::WeakPtrFactory<HttpCacheLookupManager> weak_factory_; | 63 base::WeakPtrFactory<HttpCacheLookupManager> weak_factory_; |
59 }; | 64 }; |
60 | 65 |
61 } // namespace net | 66 } // namespace net |
62 | 67 |
63 #endif // NET_HTTP_HTTP_CACHE_LOOKUP_MANAGER_H_ | 68 #endif // NET_HTTP_HTTP_CACHE_LOOKUP_MANAGER_H_ |
OLD | NEW |