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

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

Issue 5826001: net: fix callbacks in DiskCacheBasedSSLHostInfo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years 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 | Annotate | Revision Log
OLDNEW
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/lock.h" 10 #include "base/lock.h"
11 #include "base/non_thread_safe.h" 11 #include "base/non_thread_safe.h"
12 #include "base/scoped_ptr.h" 12 #include "base/scoped_ptr.h"
13 #include "base/weak_ptr.h"
13 #include "net/base/completion_callback.h" 14 #include "net/base/completion_callback.h"
14 #include "net/disk_cache/disk_cache.h" 15 #include "net/disk_cache/disk_cache.h"
15 #include "net/socket/ssl_host_info.h" 16 #include "net/socket/ssl_host_info.h"
16 17
17 namespace net { 18 namespace net {
18 19
19 class HttpCache; 20 class HttpCache;
20 class IOBuffer; 21 class IOBuffer;
21 struct SSLConfig; 22 struct SSLConfig;
22 23
(...skipping 28 matching lines...) Expand all
51 int DoOpen(); 52 int DoOpen();
52 int DoRead(); 53 int DoRead();
53 int DoCreate(); 54 int DoCreate();
54 int DoWrite(); 55 int DoWrite();
55 56
56 // WaitForDataReadyDone is the terminal state of the read operation. 57 // WaitForDataReadyDone is the terminal state of the read operation.
57 int WaitForDataReadyDone(); 58 int WaitForDataReadyDone();
58 // SetDone is the terminal state of the write operation. 59 // SetDone is the terminal state of the write operation.
59 int SetDone(); 60 int SetDone();
60 61
62 // IsCallbackPending returns true if we have a pending callback.
63 bool IsCallbackPending() const;
64
61 enum State { 65 enum State {
62 GET_BACKEND, 66 GET_BACKEND,
63 GET_BACKEND_COMPLETE, 67 GET_BACKEND_COMPLETE,
64 OPEN, 68 OPEN,
65 OPEN_COMPLETE, 69 OPEN_COMPLETE,
66 READ, 70 READ,
67 READ_COMPLETE, 71 READ_COMPLETE,
68 WAIT_FOR_DATA_READY_DONE, 72 WAIT_FOR_DATA_READY_DONE,
69 CREATE, 73 CREATE,
70 CREATE_COMPLETE, 74 CREATE_COMPLETE,
71 WRITE, 75 WRITE,
72 WRITE_COMPLETE, 76 WRITE_COMPLETE,
73 SET_DONE, 77 SET_DONE,
74 NONE, 78 NONE,
75 }; 79 };
76 80
77 scoped_refptr<CancelableCompletionCallback<DiskCacheBasedSSLHostInfo> > 81 class CallbackImpl : public CallbackRunner<Tuple1<int> > {
willchan no longer on Chromium 2010/12/15 00:03:14 Nice solution! http://google-styleguide.googlecod
agl 2010/12/15 16:28:08 Done.
78 callback_; 82 public:
83 CallbackImpl(const base::WeakPtr<DiskCacheBasedSSLHostInfo>& obj,
84 void (DiskCacheBasedSSLHostInfo::*meth) (int))
85 : obj_(obj),
86 meth_(meth) {
87 }
88
89 virtual void RunWithParams(const Tuple1<int>& params) {
90 if (!obj_) {
91 delete this;
92 } else {
93 DispatchToMethod(obj_.get(), meth_, params);
94 }
95 }
96
97 void* user_data;
willchan no longer on Chromium 2010/12/15 00:03:14 I see why you've done this, but this is also again
agl 2010/12/15 16:28:08 Rather than have the complexity of two callbacks (
98
99 protected:
100 base::WeakPtr<DiskCacheBasedSSLHostInfo> obj_;
101 void (DiskCacheBasedSSLHostInfo::*meth_) (int);
102 };
103
104 base::WeakPtrFactory<DiskCacheBasedSSLHostInfo> weak_ptr_factory_;
105 CallbackImpl* callback_;
79 State state_; 106 State state_;
80 bool ready_; 107 bool ready_;
81 std::string new_data_; 108 std::string new_data_;
82 const std::string hostname_; 109 const std::string hostname_;
83 HttpCache* const http_cache_; 110 HttpCache* const http_cache_;
84 disk_cache::Backend* backend_; 111 disk_cache::Backend* backend_;
rvargas (doing something else) 2010/12/15 02:00:16 Interesting. How do we make sure that this pointer
willchan no longer on Chromium 2010/12/15 02:14:25 The HttpCache hands out SSLHostInfos to the HttpNe
85 disk_cache::Entry *entry_; 112 disk_cache::Entry* entry_;
86 CompletionCallback* user_callback_; 113 CompletionCallback* user_callback_;
87 scoped_refptr<net::IOBuffer> read_buffer_; 114 scoped_refptr<net::IOBuffer> read_buffer_;
88 scoped_refptr<net::IOBuffer> write_buffer_; 115 scoped_refptr<net::IOBuffer> write_buffer_;
89 std::string data_; 116 std::string data_;
90 }; 117 };
91 118
92 } // namespace net 119 } // namespace net
93 120
94 #endif // NET_HTTP_DISK_CACHE_BASED_SSL_HOST_INFO_H 121 #endif // NET_HTTP_DISK_CACHE_BASED_SSL_HOST_INFO_H
OLDNEW
« no previous file with comments | « no previous file | net/http/disk_cache_based_ssl_host_info.cc » ('j') | net/http/disk_cache_based_ssl_host_info.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698