| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_SSL_HOST_INFO_H | 5 #ifndef NET_HTTP_DISK_CACHE_BASED_SSL_HOST_INFO_H |
| 6 #define NET_HTTP_DISK_CACHE_BASED_SSL_HOST_INFO_H | 6 #define NET_HTTP_DISK_CACHE_BASED_SSL_HOST_INFO_H |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 READ_COMPLETE, | 45 READ_COMPLETE, |
| 46 WAIT_FOR_DATA_READY_DONE, | 46 WAIT_FOR_DATA_READY_DONE, |
| 47 CREATE, | 47 CREATE, |
| 48 CREATE_COMPLETE, | 48 CREATE_COMPLETE, |
| 49 WRITE, | 49 WRITE, |
| 50 WRITE_COMPLETE, | 50 WRITE_COMPLETE, |
| 51 SET_DONE, | 51 SET_DONE, |
| 52 NONE, | 52 NONE, |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 ~DiskCacheBasedSSLHostInfo(); | |
| 56 | |
| 57 class CallbackImpl : public CallbackRunner<Tuple1<int> > { | 55 class CallbackImpl : public CallbackRunner<Tuple1<int> > { |
| 58 public: | 56 public: |
| 59 CallbackImpl(const base::WeakPtr<DiskCacheBasedSSLHostInfo>& obj, | 57 CallbackImpl(const base::WeakPtr<DiskCacheBasedSSLHostInfo>& obj, |
| 60 void (DiskCacheBasedSSLHostInfo::*meth) (int)) | 58 void (DiskCacheBasedSSLHostInfo::*meth) (int)); |
| 61 : obj_(obj), | 59 virtual ~CallbackImpl(); |
| 62 meth_(meth) { | |
| 63 } | |
| 64 | |
| 65 virtual void RunWithParams(const Tuple1<int>& params) { | |
| 66 if (!obj_) { | |
| 67 delete this; | |
| 68 } else { | |
| 69 DispatchToMethod(obj_.get(), meth_, params); | |
| 70 } | |
| 71 } | |
| 72 | 60 |
| 73 disk_cache::Backend** backend_pointer() { return &backend_; } | 61 disk_cache::Backend** backend_pointer() { return &backend_; } |
| 74 disk_cache::Entry** entry_pointer() { return &entry_; } | 62 disk_cache::Entry** entry_pointer() { return &entry_; } |
| 75 disk_cache::Backend* backend() const { return backend_; } | 63 disk_cache::Backend* backend() const { return backend_; } |
| 76 disk_cache::Entry* entry() const { return entry_; } | 64 disk_cache::Entry* entry() const { return entry_; } |
| 77 | 65 |
| 66 // CallbackRunner<Tuple1<int> >: |
| 67 virtual void RunWithParams(const Tuple1<int>& params); |
| 68 |
| 78 private: | 69 private: |
| 79 base::WeakPtr<DiskCacheBasedSSLHostInfo> obj_; | 70 base::WeakPtr<DiskCacheBasedSSLHostInfo> obj_; |
| 80 void (DiskCacheBasedSSLHostInfo::*meth_) (int); | 71 void (DiskCacheBasedSSLHostInfo::*meth_) (int); |
| 81 | 72 |
| 82 disk_cache::Backend* backend_; | 73 disk_cache::Backend* backend_; |
| 83 disk_cache::Entry* entry_; | 74 disk_cache::Entry* entry_; |
| 84 }; | 75 }; |
| 85 | 76 |
| 77 virtual ~DiskCacheBasedSSLHostInfo(); |
| 78 |
| 86 std::string key() const; | 79 std::string key() const; |
| 87 | 80 |
| 88 void DoLoop(int rv); | 81 void DoLoop(int rv); |
| 89 | 82 |
| 90 int DoGetBackendComplete(int rv); | 83 int DoGetBackendComplete(int rv); |
| 91 int DoOpenComplete(int rv); | 84 int DoOpenComplete(int rv); |
| 92 int DoReadComplete(int rv); | 85 int DoReadComplete(int rv); |
| 93 int DoWriteComplete(int rv); | 86 int DoWriteComplete(int rv); |
| 94 int DoCreateComplete(int rv); | 87 int DoCreateComplete(int rv); |
| 95 | 88 |
| 96 int DoGetBackend(); | 89 int DoGetBackend(); |
| 97 int DoOpen(); | 90 int DoOpen(); |
| 98 int DoRead(); | 91 int DoRead(); |
| 92 int DoWrite(); |
| 99 int DoCreate(); | 93 int DoCreate(); |
| 100 int DoWrite(); | |
| 101 | 94 |
| 102 // WaitForDataReadyDone is the terminal state of the read operation. | 95 // WaitForDataReadyDone is the terminal state of the read operation. |
| 103 int WaitForDataReadyDone(); | 96 int WaitForDataReadyDone(); |
| 97 |
| 104 // SetDone is the terminal state of the write operation. | 98 // SetDone is the terminal state of the write operation. |
| 105 int SetDone(); | 99 int SetDone(); |
| 106 | 100 |
| 107 // IsCallbackPending returns true if we have a pending callback. | 101 // IsCallbackPending returns true if we have a pending callback. |
| 108 bool IsCallbackPending() const; | 102 bool IsCallbackPending() const; |
| 109 | 103 |
| 110 base::WeakPtrFactory<DiskCacheBasedSSLHostInfo> weak_ptr_factory_; | 104 base::WeakPtrFactory<DiskCacheBasedSSLHostInfo> weak_ptr_factory_; |
| 111 CallbackImpl* callback_; | 105 CallbackImpl* callback_; |
| 112 State state_; | 106 State state_; |
| 113 bool ready_; | 107 bool ready_; |
| 114 std::string new_data_; | 108 std::string new_data_; |
| 115 const std::string hostname_; | 109 const std::string hostname_; |
| 116 HttpCache* const http_cache_; | 110 HttpCache* const http_cache_; |
| 117 disk_cache::Backend* backend_; | 111 disk_cache::Backend* backend_; |
| 118 disk_cache::Entry* entry_; | 112 disk_cache::Entry* entry_; |
| 119 CompletionCallback* user_callback_; | 113 CompletionCallback* user_callback_; |
| 120 scoped_refptr<net::IOBuffer> read_buffer_; | 114 scoped_refptr<net::IOBuffer> read_buffer_; |
| 121 scoped_refptr<net::IOBuffer> write_buffer_; | 115 scoped_refptr<net::IOBuffer> write_buffer_; |
| 122 std::string data_; | 116 std::string data_; |
| 123 }; | 117 }; |
| 124 | 118 |
| 125 } // namespace net | 119 } // namespace net |
| 126 | 120 |
| 127 #endif // NET_HTTP_DISK_CACHE_BASED_SSL_HOST_INFO_H | 121 #endif // NET_HTTP_DISK_CACHE_BASED_SSL_HOST_INFO_H |
| OLD | NEW |