| 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 class Profile; |
| 17 |
| 16 // Tracks render process host IDs that are associated with Instant. | 18 // Tracks render process host IDs that are associated with Instant. |
| 17 class InstantService : public ProfileKeyedService, | 19 class InstantService : public ProfileKeyedService, |
| 18 public content::NotificationObserver { | 20 public content::NotificationObserver { |
| 19 public: | 21 public: |
| 20 InstantService(); | 22 explicit InstantService(Profile* profile); |
| 21 virtual ~InstantService(); | 23 virtual ~InstantService(); |
| 22 | 24 |
| 23 // Add, remove, and query RenderProcessHost IDs that are associated with | 25 // Add, remove, and query RenderProcessHost IDs that are associated with |
| 24 // Instant processes. | 26 // Instant processes. |
| 25 void AddInstantProcess(int process_id); | 27 void AddInstantProcess(int process_id); |
| 26 bool IsInstantProcess(int process_id) const; | 28 bool IsInstantProcess(int process_id) const; |
| 27 | 29 |
| 28 #if defined(UNIT_TEST) | 30 #if defined(UNIT_TEST) |
| 29 int GetInstantProcessCount() const { | 31 int GetInstantProcessCount() const { |
| 30 return process_ids_.size(); | 32 return process_ids_.size(); |
| 31 } | 33 } |
| 32 #endif | 34 #endif |
| 33 | 35 |
| 34 private: | 36 private: |
| 35 // Overridden from ProfileKeyedService: | 37 // Overridden from ProfileKeyedService: |
| 36 virtual void Shutdown() OVERRIDE; | 38 virtual void Shutdown() OVERRIDE; |
| 37 | 39 |
| 38 // Overridden from content::NotificationObserver: | 40 // Overridden from content::NotificationObserver: |
| 39 virtual void Observe(int type, | 41 virtual void Observe(int type, |
| 40 const content::NotificationSource& source, | 42 const content::NotificationSource& source, |
| 41 const content::NotificationDetails& details) OVERRIDE; | 43 const content::NotificationDetails& details) OVERRIDE; |
| 42 | 44 |
| 45 Profile* const profile_; |
| 46 |
| 43 // The process ids associated with Instant processes. | 47 // The process ids associated with Instant processes. |
| 44 std::set<int> process_ids_; | 48 std::set<int> process_ids_; |
| 45 | 49 |
| 46 content::NotificationRegistrar registrar_; | 50 content::NotificationRegistrar registrar_; |
| 47 | 51 |
| 48 DISALLOW_COPY_AND_ASSIGN(InstantService); | 52 DISALLOW_COPY_AND_ASSIGN(InstantService); |
| 49 }; | 53 }; |
| 50 | 54 |
| 51 #endif // CHROME_BROWSER_INSTANT_INSTANT_SERVICE_H_ | 55 #endif // CHROME_BROWSER_INSTANT_INSTANT_SERVICE_H_ |
| OLD | NEW |