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 | 21 |
22 // DiskCacheBasedQuicServerInfo fetches information about a QUIC server from | 22 // DiskCacheBasedQuicServerInfo fetches information about a QUIC server from |
23 // our standard disk cache. Since the information is defined to be | 23 // our standard disk cache. Since the information is defined to be |
24 // non-sensitive, it's ok for us to keep it on disk. | 24 // non-sensitive, it's ok for us to keep it on disk. |
25 class NET_EXPORT_PRIVATE DiskCacheBasedQuicServerInfo | 25 class NET_EXPORT_PRIVATE DiskCacheBasedQuicServerInfo |
26 : public QuicServerInfo, | 26 : public QuicServerInfo, |
27 public NON_EXPORTED_BASE(base::NonThreadSafe) { | 27 public NON_EXPORTED_BASE(base::NonThreadSafe) { |
28 public: | 28 public: |
29 DiskCacheBasedQuicServerInfo(const std::string& hostname, | 29 DiskCacheBasedQuicServerInfo(const HostPortPair& host_port_pair, |
30 HttpCache* http_cache); | 30 HttpCache* http_cache); |
31 | 31 |
32 // QuicServerInfo implementation. | 32 // QuicServerInfo implementation. |
33 virtual void Start() OVERRIDE; | 33 virtual void Start() OVERRIDE; |
34 virtual int WaitForDataReady(const CompletionCallback& callback) OVERRIDE; | 34 virtual int WaitForDataReady(const CompletionCallback& callback) OVERRIDE; |
35 virtual bool IsDataReady() OVERRIDE; | 35 virtual bool IsDataReady() OVERRIDE; |
36 virtual void Persist() OVERRIDE; | 36 virtual void Persist() OVERRIDE; |
37 | 37 |
38 private: | 38 private: |
39 struct CacheOperationDataShim; | 39 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. | 82 // DoSetDone is the terminal state of the write operation. |
83 int DoSetDone(); | 83 int DoSetDone(); |
84 | 84 |
85 base::WeakPtrFactory<DiskCacheBasedQuicServerInfo> weak_factory_; | 85 base::WeakPtrFactory<DiskCacheBasedQuicServerInfo> weak_factory_; |
86 CacheOperationDataShim* data_shim_; // Owned by |io_callback_|. | 86 CacheOperationDataShim* data_shim_; // Owned by |io_callback_|. |
87 CompletionCallback io_callback_; | 87 CompletionCallback io_callback_; |
88 State state_; | 88 State state_; |
89 bool ready_; | 89 bool ready_; |
90 bool found_entry_; // Controls the behavior of DoCreateOrOpen. | 90 bool found_entry_; // Controls the behavior of DoCreateOrOpen. |
91 std::string new_data_; | 91 std::string new_data_; |
92 const std::string hostname_; | 92 const HostPortPair host_port_pair_; |
93 HttpCache* const http_cache_; | 93 HttpCache* const http_cache_; |
94 disk_cache::Backend* backend_; | 94 disk_cache::Backend* backend_; |
95 disk_cache::Entry* entry_; | 95 disk_cache::Entry* entry_; |
96 CompletionCallback user_callback_; | 96 CompletionCallback user_callback_; |
97 scoped_refptr<IOBuffer> read_buffer_; | 97 scoped_refptr<IOBuffer> read_buffer_; |
98 scoped_refptr<IOBuffer> write_buffer_; | 98 scoped_refptr<IOBuffer> write_buffer_; |
99 std::string data_; | 99 std::string data_; |
100 }; | 100 }; |
101 | 101 |
102 } // namespace net | 102 } // namespace net |
103 | 103 |
104 #endif // NET_HTTP_DISK_CACHE_BASED_QUIC_SERVER_INFO_H_ | 104 #endif // NET_HTTP_DISK_CACHE_BASED_QUIC_SERVER_INFO_H_ |
OLD | NEW |