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