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 #ifndef NET_DNS_SERIAL_WORKER_H_ | 5 #ifndef NET_DNS_SERIAL_WORKER_H_ |
6 #define NET_DNS_SERIAL_WORKER_H_ | 6 #define NET_DNS_SERIAL_WORKER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 friend class base::RefCountedThreadSafe<SerialWorker>; | 54 friend class base::RefCountedThreadSafe<SerialWorker>; |
55 // protected to allow sub-classing, but prevent deleting | 55 // protected to allow sub-classing, but prevent deleting |
56 virtual ~SerialWorker(); | 56 virtual ~SerialWorker(); |
57 | 57 |
58 // Executed on WorkerPool, at most once at a time. | 58 // Executed on WorkerPool, at most once at a time. |
59 virtual void DoWork() = 0; | 59 virtual void DoWork() = 0; |
60 | 60 |
61 // Executed on origin thread after |DoRead| completes. | 61 // Executed on origin thread after |DoRead| completes. |
62 virtual void OnWorkFinished() = 0; | 62 virtual void OnWorkFinished() = 0; |
63 | 63 |
64 base::MessageLoopProxy* loop() { | 64 base::MessageLoopProxy* loop() { return message_loop_.get(); } |
65 return message_loop_; | |
66 } | |
67 | 65 |
68 private: | 66 private: |
69 enum State { | 67 enum State { |
70 CANCELLED = -1, | 68 CANCELLED = -1, |
71 IDLE = 0, | 69 IDLE = 0, |
72 WORKING, // |DoWorkJob| posted on WorkerPool, until |OnWorkJobFinished| | 70 WORKING, // |DoWorkJob| posted on WorkerPool, until |OnWorkJobFinished| |
73 PENDING, // |WorkNow| while WORKING, must re-do work | 71 PENDING, // |WorkNow| while WORKING, must re-do work |
74 WAITING, // WorkerPool is busy, |RetryWork| is posted | 72 WAITING, // WorkerPool is busy, |RetryWork| is posted |
75 }; | 73 }; |
76 | 74 |
(...skipping 12 matching lines...) Expand all Loading... |
89 | 87 |
90 State state_; | 88 State state_; |
91 | 89 |
92 DISALLOW_COPY_AND_ASSIGN(SerialWorker); | 90 DISALLOW_COPY_AND_ASSIGN(SerialWorker); |
93 }; | 91 }; |
94 | 92 |
95 } // namespace net | 93 } // namespace net |
96 | 94 |
97 #endif // NET_DNS_SERIAL_WORKER_H_ | 95 #endif // NET_DNS_SERIAL_WORKER_H_ |
98 | 96 |
OLD | NEW |