| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_PRINTING_BACKGROUND_PRINTING_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_PRINTING_BACKGROUND_PRINTING_MANAGER_H_ |
| 6 #define CHROME_BROWSER_PRINTING_BACKGROUND_PRINTING_MANAGER_H_ | 6 #define CHROME_BROWSER_PRINTING_BACKGROUND_PRINTING_MANAGER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/threading/non_thread_safe.h" | 13 #include "base/threading/non_thread_safe.h" |
| 14 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
| 15 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
| 16 | 16 |
| 17 class TabContentsWrapper; |
| 18 |
| 19 namespace content { |
| 17 class RenderProcessHost; | 20 class RenderProcessHost; |
| 18 class TabContentsWrapper; | 21 } |
| 19 | 22 |
| 20 namespace printing { | 23 namespace printing { |
| 21 | 24 |
| 22 // Manages hidden tabs that prints documents in the background. | 25 // Manages hidden tabs that prints documents in the background. |
| 23 // The hidden tabs are no longer part of any Browser / TabStripModel. | 26 // The hidden tabs are no longer part of any Browser / TabStripModel. |
| 24 // They get deleted when the tab finishes printing. | 27 // They get deleted when the tab finishes printing. |
| 25 class BackgroundPrintingManager : public base::NonThreadSafe, | 28 class BackgroundPrintingManager : public base::NonThreadSafe, |
| 26 public content::NotificationObserver { | 29 public content::NotificationObserver { |
| 27 public: | 30 public: |
| 28 typedef std::set<TabContentsWrapper*> TabContentsWrapperSet; | 31 typedef std::set<TabContentsWrapper*> TabContentsWrapperSet; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 42 // Returns true if |printing_tabs_| contains |preview_tab|. | 45 // Returns true if |printing_tabs_| contains |preview_tab|. |
| 43 bool HasPrintPreviewTab(TabContentsWrapper* preview_tab); | 46 bool HasPrintPreviewTab(TabContentsWrapper* preview_tab); |
| 44 | 47 |
| 45 // content::NotificationObserver overrides: | 48 // content::NotificationObserver overrides: |
| 46 virtual void Observe(int type, | 49 virtual void Observe(int type, |
| 47 const content::NotificationSource& source, | 50 const content::NotificationSource& source, |
| 48 const content::NotificationDetails& details) OVERRIDE; | 51 const content::NotificationDetails& details) OVERRIDE; |
| 49 | 52 |
| 50 private: | 53 private: |
| 51 // Notifications handlers. | 54 // Notifications handlers. |
| 52 void OnRendererProcessClosed(RenderProcessHost* rph); | 55 void OnRendererProcessClosed(content::RenderProcessHost* rph); |
| 53 void OnPrintJobReleased(TabContentsWrapper* preview_tab); | 56 void OnPrintJobReleased(TabContentsWrapper* preview_tab); |
| 54 void OnTabContentsDestroyed(TabContentsWrapper* preview_tab); | 57 void OnTabContentsDestroyed(TabContentsWrapper* preview_tab); |
| 55 | 58 |
| 56 // Add |tab| to the pending deletion set and schedule deletion. | 59 // Add |tab| to the pending deletion set and schedule deletion. |
| 57 void DeletePreviewTab(TabContentsWrapper* tab); | 60 void DeletePreviewTab(TabContentsWrapper* tab); |
| 58 | 61 |
| 59 // Check if any of the TabContentsWrappers in |set| share a RenderProcessHost | 62 // Check if any of the TabContentsWrappers in |set| share a RenderProcessHost |
| 60 // with |tab|, excluding |tab|. | 63 // with |tab|, excluding |tab|. |
| 61 bool HasSharedRenderProcessHost(const TabContentsWrapperSet& set, | 64 bool HasSharedRenderProcessHost(const TabContentsWrapperSet& set, |
| 62 TabContentsWrapper* tab); | 65 TabContentsWrapper* tab); |
| 63 | 66 |
| 64 // The set of print preview tabs managed by BackgroundPrintingManager. | 67 // The set of print preview tabs managed by BackgroundPrintingManager. |
| 65 TabContentsWrapperSet printing_tabs_; | 68 TabContentsWrapperSet printing_tabs_; |
| 66 | 69 |
| 67 // The set of print preview tabs managed by BackgroundPrintingManager that | 70 // The set of print preview tabs managed by BackgroundPrintingManager that |
| 68 // are pending deletion. | 71 // are pending deletion. |
| 69 TabContentsWrapperSet printing_tabs_pending_deletion_; | 72 TabContentsWrapperSet printing_tabs_pending_deletion_; |
| 70 | 73 |
| 71 content::NotificationRegistrar registrar_; | 74 content::NotificationRegistrar registrar_; |
| 72 | 75 |
| 73 DISALLOW_COPY_AND_ASSIGN(BackgroundPrintingManager); | 76 DISALLOW_COPY_AND_ASSIGN(BackgroundPrintingManager); |
| 74 }; | 77 }; |
| 75 | 78 |
| 76 } // namespace printing | 79 } // namespace printing |
| 77 | 80 |
| 78 #endif // CHROME_BROWSER_PRINTING_BACKGROUND_PRINTING_MANAGER_H_ | 81 #endif // CHROME_BROWSER_PRINTING_BACKGROUND_PRINTING_MANAGER_H_ |
| OLD | NEW |