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