blob: 9bf8f5d64851cf2b80807dab6090ba25e92f2824 [file] [log] [blame]
[email protected]c5dec6292013-01-25 04:54:521// 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 CHROME_BROWSER_INSTANT_INSTANT_SERVICE_H_
6#define CHROME_BROWSER_INSTANT_INSTANT_SERVICE_H_
7
8#include <set>
9
10#include "base/basictypes.h"
11#include "base/compiler_specific.h"
12#include "chrome/browser/profiles/profile_keyed_service.h"
[email protected]54e0ee62013-02-01 17:25:0313#include "content/public/browser/notification_observer.h"
14#include "content/public/browser/notification_registrar.h"
[email protected]c5dec6292013-01-25 04:54:5215
[email protected]d572bfd2013-02-14 06:14:2016// Tracks render process host IDs that are associated with Instant.
[email protected]54e0ee62013-02-01 17:25:0317class InstantService : public ProfileKeyedService,
18 public content::NotificationObserver {
[email protected]c5dec6292013-01-25 04:54:5219 public:
20 InstantService();
21 virtual ~InstantService();
22
23 // Add, remove, and query RenderProcessHost IDs that are associated with
24 // Instant processes.
25 void AddInstantProcess(int process_id);
[email protected]c5dec6292013-01-25 04:54:5226 bool IsInstantProcess(int process_id) const;
27
[email protected]d572bfd2013-02-14 06:14:2028#if defined(UNIT_TEST)
29 int GetInstantProcessCount() const {
30 return process_ids_.size();
31 }
32#endif
[email protected]c5dec6292013-01-25 04:54:5233
34 private:
[email protected]d572bfd2013-02-14 06:14:2035 // Overridden from ProfileKeyedService:
[email protected]c5dec6292013-01-25 04:54:5236 virtual void Shutdown() OVERRIDE;
37
[email protected]d572bfd2013-02-14 06:14:2038 // Overridden from content::NotificationObserver:
[email protected]54e0ee62013-02-01 17:25:0339 virtual void Observe(int type,
40 const content::NotificationSource& source,
41 const content::NotificationDetails& details) OVERRIDE;
42
[email protected]c5dec6292013-01-25 04:54:5243 // The process ids associated with Instant processes.
44 std::set<int> process_ids_;
45
[email protected]54e0ee62013-02-01 17:25:0346 content::NotificationRegistrar registrar_;
47
[email protected]c5dec6292013-01-25 04:54:5248 DISALLOW_COPY_AND_ASSIGN(InstantService);
49};
50
51#endif // CHROME_BROWSER_INSTANT_INSTANT_SERVICE_H_