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

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

Issue 2675343002: Server push cancellation: add NetLogs to track cache lookup transaction (Closed)
Patch Set: self review Created 3 years, 10 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
OLDNEW
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);
Ryan Hamilton 2017/02/06 23:34:55 What creates an instance of this class? I don't se
Zhongyi Shi 2017/02/07 00:00:24 It should be in the HttpCache's constructor. I hav
Ryan Hamilton 2017/02/07 00:10:49 Oh, I thought this was already wired up because of
Zhongyi Shi 2017/02/07 06:01:09 As discussed offline, this CL will have minimal ef
22 const NetLogWithSource& net_log);
23 ~HttpCacheLookupManager() override; 22 ~HttpCacheLookupManager() override;
24 23
25 void OnPush(std::unique_ptr<ServerPushHelper> push_helper) override; 24 void OnPush(std::unique_ptr<ServerPushHelper> push_helper,
25 const NetLogWithSource& source) override;
Ryan Hamilton 2017/02/06 23:34:55 nit: parameters of type NetLogWithSource are typic
Zhongyi Shi 2017/02/07 06:01:08 Done.
26 26
27 // Invoked when the HttpCache::Transaction for |url| finishes to cancel the 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. 28 // server push if the response to the server push is found cached.
29 void OnLookupComplete(const GURL& url, int rv); 29 void OnLookupComplete(const GURL& url, int rv);
30 30
31 private: 31 private:
32 // A class that takes the ownership of ServerPushHelper, issues and owns an 32 // A class that takes the ownership of ServerPushHelper, issues and owns an
33 // HttpCache::Transaction which lookups the response in cache for the server 33 // HttpCache::Transaction which lookups the response in cache for the server
34 // push. 34 // push.
35 class LookupTransaction { 35 class LookupTransaction {
36 public: 36 public:
37 LookupTransaction(std::unique_ptr<ServerPushHelper> push_helper); 37 LookupTransaction(std::unique_ptr<ServerPushHelper> push_helper,
38 NetLog* net_log);
38 ~LookupTransaction(); 39 ~LookupTransaction();
39 40
40 // Issues an HttpCache::Transaction to lookup whether the response is cached 41 // Issues an HttpCache::Transaction to lookup whether the response is cached
41 // without header validation. 42 // without header validation.
42 int StartLookup(HttpCache* cache, 43 int StartLookup(HttpCache* cache,
43 const CompletionCallback& callback, 44 const CompletionCallback& callback,
44 const NetLogWithSource& net_log); 45 const NetLogWithSource& source);
45 46
46 void CancelPush(); 47 void CancelPush();
47 48
48 private: 49 private:
49 std::unique_ptr<ServerPushHelper> push_helper_; 50 std::unique_ptr<ServerPushHelper> push_helper_;
50 std::unique_ptr<HttpRequestInfo> request_; 51 std::unique_ptr<HttpRequestInfo> request_;
51 std::unique_ptr<HttpTransaction> transaction_; 52 std::unique_ptr<HttpTransaction> transaction_;
53 const NetLogWithSource net_log_;
52 }; 54 };
53 55
54 NetLogWithSource net_log_;
55 // HttpCache must outlive the HttpCacheLookupManager. 56 // HttpCache must outlive the HttpCacheLookupManager.
57 NetLog* net_log_;
Ryan Hamilton 2017/02/06 23:34:55 I think this should probably not come between |htt
Zhongyi Shi 2017/02/07 06:01:08 Done.
56 HttpCache* http_cache_; 58 HttpCache* http_cache_;
57 std::map<GURL, std::unique_ptr<LookupTransaction>> lookup_transactions_; 59 std::map<GURL, std::unique_ptr<LookupTransaction>> lookup_transactions_;
58 base::WeakPtrFactory<HttpCacheLookupManager> weak_factory_; 60 base::WeakPtrFactory<HttpCacheLookupManager> weak_factory_;
59 }; 61 };
60 62
61 } // namespace net 63 } // namespace net
62 64
63 #endif // NET_HTTP_HTTP_CACHE_LOOKUP_MANAGER_H_ 65 #endif // NET_HTTP_HTTP_CACHE_LOOKUP_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | net/http/http_cache_lookup_manager.cc » ('j') | net/http/http_cache_lookup_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698