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

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: fix typo 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
« no previous file with comments | « no previous file | net/http/http_cache_lookup_manager.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 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);
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 void OnPush(std::unique_ptr<ServerPushHelper> push_helper,
26 const NetLogWithSource& session_net_log) override;
26 27
27 // Invoked when the HttpCache::Transaction for |url| finishes to cancel the 28 // 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 // server push if the response to the server push is found cached.
29 void OnLookupComplete(const GURL& url, int rv); 30 void OnLookupComplete(const GURL& url, int rv);
30 31
31 private: 32 private:
32 // A class that takes the ownership of ServerPushHelper, issues and owns an 33 // A class that takes the ownership of ServerPushHelper, issues and owns an
33 // HttpCache::Transaction which lookups the response in cache for the server 34 // HttpCache::Transaction which lookups the response in cache for the server
34 // push. 35 // push.
35 class LookupTransaction { 36 class LookupTransaction {
36 public: 37 public:
37 LookupTransaction(std::unique_ptr<ServerPushHelper> push_helper); 38 LookupTransaction(std::unique_ptr<ServerPushHelper> push_helper,
39 NetLog* net_log);
38 ~LookupTransaction(); 40 ~LookupTransaction();
39 41
40 // Issues an HttpCache::Transaction to lookup whether the response is cached 42 // Issues an HttpCache::Transaction to lookup whether the response is cached
41 // without header validation. 43 // without header validation.
42 int StartLookup(HttpCache* cache, 44 int StartLookup(HttpCache* cache,
43 const CompletionCallback& callback, 45 const CompletionCallback& callback,
44 const NetLogWithSource& net_log); 46 const NetLogWithSource& session_net_log);
45 47
46 void CancelPush(); 48 void OnLookupComplete(int result);
47 49
48 private: 50 private:
49 std::unique_ptr<ServerPushHelper> push_helper_; 51 std::unique_ptr<ServerPushHelper> push_helper_;
50 std::unique_ptr<HttpRequestInfo> request_; 52 std::unique_ptr<HttpRequestInfo> request_;
51 std::unique_ptr<HttpTransaction> transaction_; 53 std::unique_ptr<HttpTransaction> transaction_;
54 const NetLogWithSource net_log_;
52 }; 55 };
53 56
54 NetLogWithSource net_log_;
55 // HttpCache must outlive the HttpCacheLookupManager. 57 // HttpCache must outlive the HttpCacheLookupManager.
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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698