OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ppapi/shared_impl/private/ppb_tcp_server_socket_shared.h" | 5 #include "ppapi/shared_impl/private/ppb_tcp_server_socket_shared.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 void PPB_TCPServerSocket_Shared::StopListening() { | 72 void PPB_TCPServerSocket_Shared::StopListening() { |
73 if (state_ == CLOSED) | 73 if (state_ == CLOSED) |
74 return; | 74 return; |
75 | 75 |
76 state_ = CLOSED; | 76 state_ = CLOSED; |
77 | 77 |
78 SendStopListening(); | 78 SendStopListening(); |
79 socket_id_ = 0; | 79 socket_id_ = 0; |
80 | 80 |
81 if (listen_callback_.get()) | 81 if (TrackedCallback::IsPending(listen_callback_)) |
82 listen_callback_->PostAbort(); | 82 listen_callback_->PostAbort(); |
83 if (accept_callback_.get()) | 83 if (TrackedCallback::IsPending(accept_callback_)) |
84 accept_callback_->PostAbort(); | 84 accept_callback_->PostAbort(); |
85 tcp_socket_buffer_ = NULL; | 85 tcp_socket_buffer_ = NULL; |
86 } | 86 } |
87 | 87 |
88 void PPB_TCPServerSocket_Shared::OnListenCompleted(uint32 socket_id, | 88 void PPB_TCPServerSocket_Shared::OnListenCompleted(uint32 socket_id, |
89 int32_t status) { | 89 int32_t status) { |
90 if (state_ != BEFORE_LISTENING || | 90 if (state_ != BEFORE_LISTENING || |
91 !TrackedCallback::IsPending(listen_callback_)) { | 91 !TrackedCallback::IsPending(listen_callback_)) { |
92 NOTREACHED(); | 92 NOTREACHED(); |
93 return; | 93 return; |
94 } | 94 } |
95 | 95 |
96 if (status == PP_OK) { | 96 if (status == PP_OK) { |
97 socket_id_ = socket_id; | 97 socket_id_ = socket_id; |
98 state_ = LISTENING; | 98 state_ = LISTENING; |
99 } | 99 } |
100 | 100 |
101 TrackedCallback::ClearAndRun(&listen_callback_, status); | 101 listen_callback_->Run(status); |
102 } | 102 } |
103 | 103 |
104 } // namespace ppapi | 104 } // namespace ppapi |
OLD | NEW |