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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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() { |
65 return message_loop_; | 65 return message_loop_.get(); |
66 } | 66 } |
67 | 67 |
68 private: | 68 private: |
69 enum State { | 69 enum State { |
70 CANCELLED = -1, | 70 CANCELLED = -1, |
71 IDLE = 0, | 71 IDLE = 0, |
72 WORKING, // |DoWorkJob| posted on WorkerPool, until |OnWorkJobFinished| | 72 WORKING, // |DoWorkJob| posted on WorkerPool, until |OnWorkJobFinished| |
73 PENDING, // |WorkNow| while WORKING, must re-do work | 73 PENDING, // |WorkNow| while WORKING, must re-do work |
74 WAITING, // WorkerPool is busy, |RetryWork| is posted | 74 WAITING, // WorkerPool is busy, |RetryWork| is posted |
75 }; | 75 }; |
(...skipping 13 matching lines...) Expand all Loading... |
89 | 89 |
90 State state_; | 90 State state_; |
91 | 91 |
92 DISALLOW_COPY_AND_ASSIGN(SerialWorker); | 92 DISALLOW_COPY_AND_ASSIGN(SerialWorker); |
93 }; | 93 }; |
94 | 94 |
95 } // namespace net | 95 } // namespace net |
96 | 96 |
97 #endif // NET_DNS_SERIAL_WORKER_H_ | 97 #endif // NET_DNS_SERIAL_WORKER_H_ |
98 | 98 |
OLD | NEW |