[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 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 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] | 54e0ee6 | 2013-02-01 17:25:03 | [diff] [blame] | 13 | #include "content/public/browser/notification_observer.h" |
14 | #include "content/public/browser/notification_registrar.h" | ||||
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 15 | |
[email protected] | d572bfd | 2013-02-14 06:14:20 | [diff] [blame^] | 16 | // Tracks render process host IDs that are associated with Instant. |
[email protected] | 54e0ee6 | 2013-02-01 17:25:03 | [diff] [blame] | 17 | class InstantService : public ProfileKeyedService, |
18 | public content::NotificationObserver { | ||||
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 19 | 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] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 26 | bool IsInstantProcess(int process_id) const; |
27 | |||||
[email protected] | d572bfd | 2013-02-14 06:14:20 | [diff] [blame^] | 28 | #if defined(UNIT_TEST) |
29 | int GetInstantProcessCount() const { | ||||
30 | return process_ids_.size(); | ||||
31 | } | ||||
32 | #endif | ||||
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 33 | |
34 | private: | ||||
[email protected] | d572bfd | 2013-02-14 06:14:20 | [diff] [blame^] | 35 | // Overridden from ProfileKeyedService: |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 36 | virtual void Shutdown() OVERRIDE; |
37 | |||||
[email protected] | d572bfd | 2013-02-14 06:14:20 | [diff] [blame^] | 38 | // Overridden from content::NotificationObserver: |
[email protected] | 54e0ee6 | 2013-02-01 17:25:03 | [diff] [blame] | 39 | virtual void Observe(int type, |
40 | const content::NotificationSource& source, | ||||
41 | const content::NotificationDetails& details) OVERRIDE; | ||||
42 | |||||
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 43 | // The process ids associated with Instant processes. |
44 | std::set<int> process_ids_; | ||||
45 | |||||
[email protected] | 54e0ee6 | 2013-02-01 17:25:03 | [diff] [blame] | 46 | content::NotificationRegistrar registrar_; |
47 | |||||
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 48 | DISALLOW_COPY_AND_ASSIGN(InstantService); |
49 | }; | ||||
50 | |||||
51 | #endif // CHROME_BROWSER_INSTANT_INSTANT_SERVICE_H_ |