| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 // Unless already scheduled, post |DoWork| to WorkerPool. | 45 // Unless already scheduled, post |DoWork| to WorkerPool. |
| 46 // Made virtual to allow mocking. | 46 // Made virtual to allow mocking. |
| 47 virtual void WorkNow(); | 47 virtual void WorkNow(); |
| 48 | 48 |
| 49 // Stop scheduling jobs. | 49 // Stop scheduling jobs. |
| 50 void Cancel(); | 50 void Cancel(); |
| 51 | 51 |
| 52 bool IsCancelled() const { return state_ == CANCELLED; } | 52 bool IsCancelled() const { return state_ == CANCELLED; } |
| 53 | 53 |
| 54 // Delay between calls to WorkerPool::PostTask | |
| 55 static const int kWorkerPoolRetryDelayMs = 100; | |
| 56 | |
| 57 protected: | 54 protected: |
| 58 friend class base::RefCountedThreadSafe<SerialWorker>; | 55 friend class base::RefCountedThreadSafe<SerialWorker>; |
| 59 // protected to allow sub-classing, but prevent deleting | 56 // protected to allow sub-classing, but prevent deleting |
| 60 virtual ~SerialWorker(); | 57 virtual ~SerialWorker(); |
| 61 | 58 |
| 62 // Executed on WorkerPool, at most once at a time. | 59 // Executed on WorkerPool, at most once at a time. |
| 63 virtual void DoWork() = 0; | 60 virtual void DoWork() = 0; |
| 64 | 61 |
| 65 // Executed on origin thread after |DoRead| completes. | 62 // Executed on origin thread after |DoRead| completes. |
| 66 virtual void OnWorkFinished() = 0; | 63 virtual void OnWorkFinished() = 0; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 93 | 90 |
| 94 State state_; | 91 State state_; |
| 95 | 92 |
| 96 DISALLOW_COPY_AND_ASSIGN(SerialWorker); | 93 DISALLOW_COPY_AND_ASSIGN(SerialWorker); |
| 97 }; | 94 }; |
| 98 | 95 |
| 99 } // namespace net | 96 } // namespace net |
| 100 | 97 |
| 101 #endif // NET_DNS_SERIAL_WORKER_H_ | 98 #endif // NET_DNS_SERIAL_WORKER_H_ |
| 102 | 99 |
| OLD | NEW |