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

Side by Side Diff: net/socket/tcp_client_socket_win.cc

Issue 368001: Second patch in making destructors of refcounted objects private. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #include "net/socket/tcp_client_socket_win.h" 5 #include "net/socket/tcp_client_socket_win.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/field_trial.h" // for SlowStart trial 9 #include "base/field_trial.h" // for SlowStart trial
10 #include "base/memory_debug.h" 10 #include "base/memory_debug.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 //----------------------------------------------------------------------------- 119 //-----------------------------------------------------------------------------
120 120
121 // This class encapsulates all the state that has to be preserved as long as 121 // This class encapsulates all the state that has to be preserved as long as
122 // there is a network IO operation in progress. If the owner TCPClientSocketWin 122 // there is a network IO operation in progress. If the owner TCPClientSocketWin
123 // is destroyed while an operation is in progress, the Core is detached and it 123 // is destroyed while an operation is in progress, the Core is detached and it
124 // lives until the operation completes and the OS doesn't reference any resource 124 // lives until the operation completes and the OS doesn't reference any resource
125 // declared on this class anymore. 125 // declared on this class anymore.
126 class TCPClientSocketWin::Core : public base::RefCounted<Core> { 126 class TCPClientSocketWin::Core : public base::RefCounted<Core> {
127 public: 127 public:
128 explicit Core(TCPClientSocketWin* socket); 128 explicit Core(TCPClientSocketWin* socket);
129 ~Core();
130 129
131 // Start watching for the end of a read or write operation. 130 // Start watching for the end of a read or write operation.
132 void WatchForRead(); 131 void WatchForRead();
133 void WatchForWrite(); 132 void WatchForWrite();
134 133
135 // The TCPClientSocketWin is going away. 134 // The TCPClientSocketWin is going away.
136 void Detach() { socket_ = NULL; } 135 void Detach() { socket_ = NULL; }
137 136
138 // The separate OVERLAPPED variables for asynchronous operation. 137 // The separate OVERLAPPED variables for asynchronous operation.
139 // |read_overlapped_| is used for both Connect() and Read(). 138 // |read_overlapped_| is used for both Connect() and Read().
(...skipping 14 matching lines...) Expand all
154 return size; 153 return size;
155 154
156 if (slow_start_throttle_ < kMaxSlowStartThrottle) { 155 if (slow_start_throttle_ < kMaxSlowStartThrottle) {
157 size = std::min(size, slow_start_throttle_); 156 size = std::min(size, slow_start_throttle_);
158 slow_start_throttle_ *= 2; 157 slow_start_throttle_ *= 2;
159 } 158 }
160 return size; 159 return size;
161 } 160 }
162 161
163 private: 162 private:
163 friend class base::RefCounted<Core>;
164
165 ~Core();
eroman 2009/11/05 20:52:19 nit: move this after the inner class definitions.
jam 2009/11/05 21:56:02 Done.
166
164 class ReadDelegate : public base::ObjectWatcher::Delegate { 167 class ReadDelegate : public base::ObjectWatcher::Delegate {
165 public: 168 public:
166 explicit ReadDelegate(Core* core) : core_(core) {} 169 explicit ReadDelegate(Core* core) : core_(core) {}
167 virtual ~ReadDelegate() {} 170 virtual ~ReadDelegate() {}
168 171
169 // base::ObjectWatcher::Delegate methods: 172 // base::ObjectWatcher::Delegate methods:
170 virtual void OnObjectSignaled(HANDLE object); 173 virtual void OnObjectSignaled(HANDLE object);
171 174
172 private: 175 private:
173 Core* const core_; 176 Core* const core_;
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 BOOL ok = WSAGetOverlappedResult(socket_, &core_->write_overlapped_, 694 BOOL ok = WSAGetOverlappedResult(socket_, &core_->write_overlapped_,
692 &num_bytes, FALSE, &flags); 695 &num_bytes, FALSE, &flags);
693 WSAResetEvent(core_->write_overlapped_.hEvent); 696 WSAResetEvent(core_->write_overlapped_.hEvent);
694 TRACE_EVENT_END("socket.write", this, StringPrintf("%d bytes", num_bytes)); 697 TRACE_EVENT_END("socket.write", this, StringPrintf("%d bytes", num_bytes));
695 waiting_write_ = false; 698 waiting_write_ = false;
696 core_->write_iobuffer_ = NULL; 699 core_->write_iobuffer_ = NULL;
697 DoWriteCallback(ok ? num_bytes : MapWinsockError(WSAGetLastError())); 700 DoWriteCallback(ok ? num_bytes : MapWinsockError(WSAGetLastError()));
698 } 701 }
699 702
700 } // namespace net 703 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698