OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_DISK_CACHE_BASED_QUIC_SERVER_INFO_H_ | 5 #ifndef NET_HTTP_DISK_CACHE_BASED_QUIC_SERVER_INFO_H_ |
6 #define NET_HTTP_DISK_CACHE_BASED_QUIC_SERVER_INFO_H_ | 6 #define NET_HTTP_DISK_CACHE_BASED_QUIC_SERVER_INFO_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/threading/non_thread_safe.h" | 12 #include "base/threading/non_thread_safe.h" |
13 #include "net/base/completion_callback.h" | 13 #include "net/base/completion_callback.h" |
14 #include "net/disk_cache/disk_cache.h" | 14 #include "net/disk_cache/disk_cache.h" |
15 #include "net/quic/crypto/quic_server_info.h" | 15 #include "net/quic/crypto/quic_server_info.h" |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 | 18 |
19 class HttpCache; | 19 class HttpCache; |
20 class IOBuffer; | 20 class IOBuffer; |
| 21 class QuicSessionKey; |
21 | 22 |
22 // DiskCacheBasedQuicServerInfo fetches information about a QUIC server from | 23 // DiskCacheBasedQuicServerInfo fetches information about a QUIC server from |
23 // our standard disk cache. Since the information is defined to be | 24 // our standard disk cache. Since the information is defined to be |
24 // non-sensitive, it's ok for us to keep it on disk. | 25 // non-sensitive, it's ok for us to keep it on disk. |
25 class NET_EXPORT_PRIVATE DiskCacheBasedQuicServerInfo | 26 class NET_EXPORT_PRIVATE DiskCacheBasedQuicServerInfo |
26 : public QuicServerInfo, | 27 : public QuicServerInfo, |
27 public NON_EXPORTED_BASE(base::NonThreadSafe) { | 28 public NON_EXPORTED_BASE(base::NonThreadSafe) { |
28 public: | 29 public: |
29 DiskCacheBasedQuicServerInfo(const std::string& hostname, | 30 DiskCacheBasedQuicServerInfo(const QuicSessionKey& server_key, |
30 HttpCache* http_cache); | 31 HttpCache* http_cache); |
31 | 32 |
32 // QuicServerInfo implementation. | 33 // QuicServerInfo implementation. |
33 virtual void Start() OVERRIDE; | 34 virtual void Start() OVERRIDE; |
34 virtual int WaitForDataReady(const CompletionCallback& callback) OVERRIDE; | 35 virtual int WaitForDataReady(const CompletionCallback& callback) OVERRIDE; |
35 virtual bool IsDataReady() OVERRIDE; | 36 virtual bool IsDataReady() OVERRIDE; |
36 virtual void Persist() OVERRIDE; | 37 virtual void Persist() OVERRIDE; |
37 | 38 |
38 private: | 39 private: |
39 struct CacheOperationDataShim; | 40 struct CacheOperationDataShim; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 // DoSetDone is the terminal state of the write operation. | 83 // DoSetDone is the terminal state of the write operation. |
83 int DoSetDone(); | 84 int DoSetDone(); |
84 | 85 |
85 base::WeakPtrFactory<DiskCacheBasedQuicServerInfo> weak_factory_; | 86 base::WeakPtrFactory<DiskCacheBasedQuicServerInfo> weak_factory_; |
86 CacheOperationDataShim* data_shim_; // Owned by |io_callback_|. | 87 CacheOperationDataShim* data_shim_; // Owned by |io_callback_|. |
87 CompletionCallback io_callback_; | 88 CompletionCallback io_callback_; |
88 State state_; | 89 State state_; |
89 bool ready_; | 90 bool ready_; |
90 bool found_entry_; // Controls the behavior of DoCreateOrOpen. | 91 bool found_entry_; // Controls the behavior of DoCreateOrOpen. |
91 std::string new_data_; | 92 std::string new_data_; |
92 const std::string hostname_; | 93 const QuicSessionKey server_key_; |
93 HttpCache* const http_cache_; | 94 HttpCache* const http_cache_; |
94 disk_cache::Backend* backend_; | 95 disk_cache::Backend* backend_; |
95 disk_cache::Entry* entry_; | 96 disk_cache::Entry* entry_; |
96 CompletionCallback user_callback_; | 97 CompletionCallback user_callback_; |
97 scoped_refptr<IOBuffer> read_buffer_; | 98 scoped_refptr<IOBuffer> read_buffer_; |
98 scoped_refptr<IOBuffer> write_buffer_; | 99 scoped_refptr<IOBuffer> write_buffer_; |
99 std::string data_; | 100 std::string data_; |
100 }; | 101 }; |
101 | 102 |
102 } // namespace net | 103 } // namespace net |
103 | 104 |
104 #endif // NET_HTTP_DISK_CACHE_BASED_QUIC_SERVER_INFO_H_ | 105 #endif // NET_HTTP_DISK_CACHE_BASED_QUIC_SERVER_INFO_H_ |
OLD | NEW |