| 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 19 matching lines...) Expand all Loading... |
| 30 // | 30 // |
| 31 // Derived classes should store results of work done in |DoWork| in dedicated | 31 // Derived classes should store results of work done in |DoWork| in dedicated |
| 32 // fields and read them in |OnWorkFinished| which is executed on the origin | 32 // fields and read them in |OnWorkFinished| which is executed on the origin |
| 33 // thread. This avoids the need to template this class. | 33 // thread. This avoids the need to template this class. |
| 34 // | 34 // |
| 35 // This implementation avoids locking by using the |state_| member to ensure | 35 // This implementation avoids locking by using the |state_| member to ensure |
| 36 // that |DoWork| and |OnWorkFinished| cannot execute in parallel. | 36 // that |DoWork| and |OnWorkFinished| cannot execute in parallel. |
| 37 // | 37 // |
| 38 // TODO(szym): update to WorkerPool::PostTaskAndReply once available. | 38 // TODO(szym): update to WorkerPool::PostTaskAndReply once available. |
| 39 class NET_EXPORT_PRIVATE SerialWorker | 39 class NET_EXPORT_PRIVATE SerialWorker |
| 40 : NON_EXPORTED_BASE(public base::RefCountedThreadSafe<SerialWorker>) { | 40 : NON_EXPORTED_BASE(public base::RefCountedThreadSafe<SerialWorker>) { |
| 41 public: | 41 public: |
| 42 SerialWorker(); | 42 SerialWorker(); |
| 43 | 43 |
| 44 // Unless already scheduled, post |DoWork| to WorkerPool. | 44 // Unless already scheduled, post |DoWork| to WorkerPool. |
| 45 // Made virtual to allow mocking. | 45 // Made virtual to allow mocking. |
| 46 virtual void WorkNow(); | 46 virtual void WorkNow(); |
| 47 | 47 |
| 48 // Stop scheduling jobs. | 48 // Stop scheduling jobs. |
| 49 void Cancel(); | 49 void Cancel(); |
| 50 | 50 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 scoped_refptr<base::MessageLoopProxy> message_loop_; | 86 scoped_refptr<base::MessageLoopProxy> message_loop_; |
| 87 | 87 |
| 88 State state_; | 88 State state_; |
| 89 | 89 |
| 90 DISALLOW_COPY_AND_ASSIGN(SerialWorker); | 90 DISALLOW_COPY_AND_ASSIGN(SerialWorker); |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 } // namespace net | 93 } // namespace net |
| 94 | 94 |
| 95 #endif // NET_DNS_SERIAL_WORKER_H_ | 95 #endif // NET_DNS_SERIAL_WORKER_H_ |
| 96 | |
| OLD | NEW |