1a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved.
2a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
3a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// found in the LICENSE file.
4a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
5a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#ifndef COMPONENTS_KEYED_SERVICE_CORE_KEYED_SERVICE_H_
6a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#define COMPONENTS_KEYED_SERVICE_CORE_KEYED_SERVICE_H_
7a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
8a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "components/keyed_service/core/keyed_service_export.h"
9a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
10a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Interface for keyed services that support two-phase destruction order.
11a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)//
12a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Two-phase shutdown allows keyed services to have a first pass shutdown phase
13a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// where they drop references. Not all services will need this, so there's a
14a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// default implementation. Only once every service has been given a chance to
15a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// drop references are services deleted.
16a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)class KEYED_SERVICE_EXPORT KeyedService {
17a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) public:
18f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  KeyedService();
19f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)
20a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // The first pass is to call Shutdown on a KeyedService.
21f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  virtual void Shutdown();
22a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
23a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // The second pass is the actual deletion of each object.
24f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  virtual ~KeyedService();
25a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)};
26a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
27a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#endif  // COMPONENTS_KEYED_SERVICE_CORE_KEYED_SERVICE_H_
28