OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/renderer_host/pepper_message_filter.h" | 5 #include "content/browser/renderer_host/pepper_message_filter.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 if (fd != -1) { | 269 if (fd != -1) { |
270 socket_for_transit = base::FileDescriptor(fd, true); | 270 socket_for_transit = base::FileDescriptor(fd, true); |
271 break; | 271 break; |
272 } | 272 } |
273 } | 273 } |
274 } | 274 } |
275 | 275 |
276 BrowserThread::PostTask( | 276 BrowserThread::PostTask( |
277 BrowserThread::IO, | 277 BrowserThread::IO, |
278 FROM_HERE, | 278 FROM_HERE, |
279 base::IgnoreReturn<bool>( | 279 base::Bind( |
280 base::Bind( | 280 base::IgnoreResult(&PepperMessageFilter::Send), this, |
281 &PepperMessageFilter::Send, this, | 281 new PepperMsg_ConnectTcpACK( |
282 new PepperMsg_ConnectTcpACK( | 282 routing_id, request_id, |
283 routing_id, request_id, | 283 socket_for_transit, local_addr, remote_addr))); |
284 socket_for_transit, local_addr, remote_addr)))); | |
285 } | 284 } |
286 | 285 |
287 // TODO(vluu): Eliminate duplication between this and | 286 // TODO(vluu): Eliminate duplication between this and |
288 // |ConnectTcpOnWorkerThread()|. | 287 // |ConnectTcpOnWorkerThread()|. |
289 void PepperMessageFilter::ConnectTcpAddressOnWorkerThread( | 288 void PepperMessageFilter::ConnectTcpAddressOnWorkerThread( |
290 int routing_id, | 289 int routing_id, |
291 int request_id, | 290 int request_id, |
292 PP_NetAddress_Private addr) { | 291 PP_NetAddress_Private addr) { |
293 IPC::PlatformFileForTransit socket_for_transit = | 292 IPC::PlatformFileForTransit socket_for_transit = |
294 IPC::InvalidPlatformFileForTransit(); | 293 IPC::InvalidPlatformFileForTransit(); |
295 PP_NetAddress_Private local_addr = NetAddressPrivateImpl::kInvalidNetAddress; | 294 PP_NetAddress_Private local_addr = NetAddressPrivateImpl::kInvalidNetAddress; |
296 PP_NetAddress_Private remote_addr = NetAddressPrivateImpl::kInvalidNetAddress; | 295 PP_NetAddress_Private remote_addr = NetAddressPrivateImpl::kInvalidNetAddress; |
297 | 296 |
298 int fd = ConnectTcpSocket(addr, &local_addr, &remote_addr); | 297 int fd = ConnectTcpSocket(addr, &local_addr, &remote_addr); |
299 if (fd != -1) | 298 if (fd != -1) |
300 socket_for_transit = base::FileDescriptor(fd, true); | 299 socket_for_transit = base::FileDescriptor(fd, true); |
301 | 300 |
302 BrowserThread::PostTask( | 301 BrowserThread::PostTask( |
303 BrowserThread::IO, | 302 BrowserThread::IO, |
304 FROM_HERE, | 303 FROM_HERE, |
305 base::IgnoreReturn<bool>( | 304 base::Bind( |
306 base::Bind( | 305 base::IgnoreResult(&PepperMessageFilter::Send), this, |
307 &PepperMessageFilter::Send, this, | 306 new PepperMsg_ConnectTcpACK( |
308 new PepperMsg_ConnectTcpACK( | 307 routing_id, request_id, |
309 routing_id, request_id, | 308 socket_for_transit, local_addr, remote_addr))); |
310 socket_for_transit, local_addr, remote_addr)))); | |
311 } | 309 } |
312 | 310 |
313 #endif // ENABLE_FLAPPER_HACKS | 311 #endif // ENABLE_FLAPPER_HACKS |
314 | 312 |
315 void PepperMessageFilter::OnGetLocalTimeZoneOffset(base::Time t, | 313 void PepperMessageFilter::OnGetLocalTimeZoneOffset(base::Time t, |
316 double* result) { | 314 double* result) { |
317 // Explode it to local time and then unexplode it as if it were UTC. Also | 315 // Explode it to local time and then unexplode it as if it were UTC. Also |
318 // explode it to UTC and unexplode it (this avoids mismatching rounding or | 316 // explode it to UTC and unexplode it (this avoids mismatching rounding or |
319 // lack thereof). The time zone offset is their difference. | 317 // lack thereof). The time zone offset is their difference. |
320 // | 318 // |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 do { | 521 do { |
524 // Although it is unlikely, make sure that we won't cause any trouble when | 522 // Although it is unlikely, make sure that we won't cause any trouble when |
525 // the counter overflows. | 523 // the counter overflows. |
526 socket_id = next_socket_id_++; | 524 socket_id = next_socket_id_++; |
527 } while (socket_id == kInvalidSocketID || | 525 } while (socket_id == kInvalidSocketID || |
528 tcp_sockets_.find(socket_id) != tcp_sockets_.end() || | 526 tcp_sockets_.find(socket_id) != tcp_sockets_.end() || |
529 udp_sockets_.find(socket_id) != udp_sockets_.end()); | 527 udp_sockets_.find(socket_id) != udp_sockets_.end()); |
530 | 528 |
531 return socket_id; | 529 return socket_id; |
532 } | 530 } |
OLD | NEW |