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 CHROME_BROWSER_INSTANT_INSTANT_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_INSTANT_INSTANT_SERVICE_H_ |
6 #define CHROME_BROWSER_INSTANT_INSTANT_SERVICE_H_ | 6 #define CHROME_BROWSER_INSTANT_INSTANT_SERVICE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "chrome/browser/profiles/profile_keyed_service.h" | 12 #include "chrome/browser/profiles/profile_keyed_service.h" |
13 #include "content/public/browser/notification_observer.h" | 13 #include "content/public/browser/notification_observer.h" |
14 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
15 | 15 |
16 // Tracks render process host ids that are associated with Instant. | 16 // Tracks render process host IDs that are associated with Instant. |
17 class InstantService : public ProfileKeyedService, | 17 class InstantService : public ProfileKeyedService, |
18 public content::NotificationObserver { | 18 public content::NotificationObserver { |
19 public: | 19 public: |
20 InstantService(); | 20 InstantService(); |
21 virtual ~InstantService(); | 21 virtual ~InstantService(); |
22 | 22 |
23 // Add, remove, and query RenderProcessHost IDs that are associated with | 23 // Add, remove, and query RenderProcessHost IDs that are associated with |
24 // Instant processes. | 24 // Instant processes. |
25 void AddInstantProcess(int process_id); | 25 void AddInstantProcess(int process_id); |
26 bool IsInstantProcess(int process_id) const; | 26 bool IsInstantProcess(int process_id) const; |
27 | 27 |
28 // For testing. | 28 #if defined(UNIT_TEST) |
29 int GetInstantProcessCount() const; | 29 int GetInstantProcessCount() const { |
| 30 return process_ids_.size(); |
| 31 } |
| 32 #endif |
30 | 33 |
31 private: | 34 private: |
32 // ProfileKeyedService: | 35 // Overridden from ProfileKeyedService: |
33 virtual void Shutdown() OVERRIDE; | 36 virtual void Shutdown() OVERRIDE; |
34 | 37 |
| 38 // Overridden from content::NotificationObserver: |
35 virtual void Observe(int type, | 39 virtual void Observe(int type, |
36 const content::NotificationSource& source, | 40 const content::NotificationSource& source, |
37 const content::NotificationDetails& details) OVERRIDE; | 41 const content::NotificationDetails& details) OVERRIDE; |
38 | 42 |
39 // The process ids associated with Instant processes. | 43 // The process ids associated with Instant processes. |
40 std::set<int> process_ids_; | 44 std::set<int> process_ids_; |
41 | 45 |
42 content::NotificationRegistrar registrar_; | 46 content::NotificationRegistrar registrar_; |
43 | 47 |
44 DISALLOW_COPY_AND_ASSIGN(InstantService); | 48 DISALLOW_COPY_AND_ASSIGN(InstantService); |
45 }; | 49 }; |
46 | 50 |
47 #endif // CHROME_BROWSER_INSTANT_INSTANT_SERVICE_H_ | 51 #endif // CHROME_BROWSER_INSTANT_INSTANT_SERVICE_H_ |
OLD | NEW |