OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CONTENT_CHILD_SCOPED_CHILD_PROCESS_REFERENCE_H_ | 5 #ifndef CONTENT_CHILD_SCOPED_CHILD_PROCESS_REFERENCE_H_ |
6 #define CONTENT_CHILD_SCOPED_CHILD_PROCESS_REFERENCE_H_ | 6 #define CONTENT_CHILD_SCOPED_CHILD_PROCESS_REFERENCE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/macros.h" |
9 | 9 |
10 namespace base { | 10 namespace base { |
11 class TimeDelta; | 11 class TimeDelta; |
12 } | 12 } |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 | 15 |
16 // Scoper class that automatically adds a reference to the current child | 16 // Scoper class that automatically adds a reference to the current child |
17 // process in constructor and releases the reference on scope out. | 17 // process in constructor and releases the reference on scope out. |
18 // Consumers of this class can call ReleaseWithDelay() to explicitly release | 18 // Consumers of this class can call ReleaseWithDelay() to explicitly release |
19 // the reference with a certain delay. | 19 // the reference with a certain delay. |
20 class ScopedChildProcessReference { | 20 class ScopedChildProcessReference { |
21 public: | 21 public: |
22 ScopedChildProcessReference(); | 22 ScopedChildProcessReference(); |
23 ~ScopedChildProcessReference(); | 23 ~ScopedChildProcessReference(); |
24 | 24 |
25 // Releases the process reference after |delay|. Once this is called | 25 // Releases the process reference after |delay|. Once this is called |
26 // scoping out has no effect. | 26 // scoping out has no effect. |
27 // It is not valid to call this more than once. | 27 // It is not valid to call this more than once. |
28 void ReleaseWithDelay(const base::TimeDelta& delay); | 28 void ReleaseWithDelay(const base::TimeDelta& delay); |
29 | 29 |
30 private: | 30 private: |
31 bool has_reference_; | 31 bool has_reference_; |
| 32 |
32 DISALLOW_COPY_AND_ASSIGN(ScopedChildProcessReference); | 33 DISALLOW_COPY_AND_ASSIGN(ScopedChildProcessReference); |
33 }; | 34 }; |
34 | 35 |
35 } // namespace content | 36 } // namespace content |
36 | 37 |
37 #endif // CONTENT_CHILD_SCOPED_CHILD_PROCESS_REFERENCE_H_ | 38 #endif // CONTENT_CHILD_SCOPED_CHILD_PROCESS_REFERENCE_H_ |
OLD | NEW |