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

Side by Side Diff: net/tools/quic/quic_epoll_connection_helper.cc

Issue 992733002: Remove //net (except for Android test stuff) and sdch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 months 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "net/tools/quic/quic_epoll_connection_helper.h"
6
7 #include <errno.h>
8 #include <sys/socket.h>
9
10 #include "base/logging.h"
11 #include "base/stl_util.h"
12 #include "net/base/ip_endpoint.h"
13 #include "net/quic/crypto/quic_random.h"
14 #include "net/tools/epoll_server/epoll_server.h"
15 #include "net/tools/quic/quic_socket_utils.h"
16
17 namespace net {
18 namespace tools {
19
20 namespace {
21
22 class QuicEpollAlarm : public QuicAlarm {
23 public:
24 QuicEpollAlarm(EpollServer* epoll_server,
25 QuicAlarm::Delegate* delegate)
26 : QuicAlarm(delegate),
27 epoll_server_(epoll_server),
28 epoll_alarm_impl_(this) {}
29
30 protected:
31 void SetImpl() override {
32 DCHECK(deadline().IsInitialized());
33 epoll_server_->RegisterAlarm(
34 deadline().Subtract(QuicTime::Zero()).ToMicroseconds(),
35 &epoll_alarm_impl_);
36 }
37
38 void CancelImpl() override {
39 DCHECK(!deadline().IsInitialized());
40 epoll_alarm_impl_.UnregisterIfRegistered();
41 }
42
43 private:
44 class EpollAlarmImpl : public EpollAlarm {
45 public:
46 explicit EpollAlarmImpl(QuicEpollAlarm* alarm) : alarm_(alarm) {}
47
48 int64 OnAlarm() override {
49 EpollAlarm::OnAlarm();
50 alarm_->Fire();
51 // Fire will take care of registering the alarm, if needed.
52 return 0;
53 }
54
55 private:
56 QuicEpollAlarm* alarm_;
57 };
58
59 EpollServer* epoll_server_;
60 EpollAlarmImpl epoll_alarm_impl_;
61 };
62
63 } // namespace
64
65 QuicEpollConnectionHelper::QuicEpollConnectionHelper(EpollServer* epoll_server)
66 : epoll_server_(epoll_server),
67 clock_(epoll_server),
68 random_generator_(QuicRandom::GetInstance()) {
69 }
70
71 QuicEpollConnectionHelper::~QuicEpollConnectionHelper() {
72 }
73
74 const QuicClock* QuicEpollConnectionHelper::GetClock() const {
75 return &clock_;
76 }
77
78 QuicRandom* QuicEpollConnectionHelper::GetRandomGenerator() {
79 return random_generator_;
80 }
81
82 QuicAlarm* QuicEpollConnectionHelper::CreateAlarm(
83 QuicAlarm::Delegate* delegate) {
84 return new QuicEpollAlarm(epoll_server_, delegate);
85 }
86
87 } // namespace tools
88 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_epoll_connection_helper.h ('k') | net/tools/quic/quic_epoll_connection_helper_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698