Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(822)

Side by Side Diff: chrome/browser/printing/background_printing_manager.h

Issue 133013002: Remove render process and WebContents notifications from background printing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/printing/background_printing_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/threading/non_thread_safe.h" 12 #include "base/threading/non_thread_safe.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 namespace content { 16 namespace content {
17 class RenderProcessHost; 17 class RenderProcessHost;
18 class WebContents; 18 class WebContents;
19 } 19 }
20 20
21 namespace printing { 21 namespace printing {
22 22
23 // Manages hidden WebContents that prints documents in the background. 23 // Manages hidden WebContents that prints documents in the background.
24 // The hidden WebContents are no longer part of any Browser / TabStripModel. 24 // The hidden WebContents are no longer part of any Browser / TabStripModel.
25 // The WebContents started life as a ConstrainedPrintPreview dialog. 25 // The WebContents started life as a ConstrainedPrintPreview dialog.
26 // They get deleted when the printing finishes. 26 // They get deleted when the printing finishes.
27 class BackgroundPrintingManager : public base::NonThreadSafe, 27 class BackgroundPrintingManager : public base::NonThreadSafe,
28 public content::NotificationObserver { 28 public content::NotificationObserver {
29 public: 29 public:
30 typedef std::set<content::WebContents*> WebContentsSet; 30 class Observer;
31 typedef std::map<content::WebContents*, Observer*> WebContentsObserverMap;
31 32
32 BackgroundPrintingManager(); 33 BackgroundPrintingManager();
33 virtual ~BackgroundPrintingManager(); 34 virtual ~BackgroundPrintingManager();
34 35
35 // Takes ownership of |preview_dialog| and deletes it when |preview_dialog| 36 // Takes ownership of |preview_dialog| and deletes it when |preview_dialog|
36 // finishes printing. This removes |preview_dialog| from its ConstrainedDialog 37 // finishes printing. This removes |preview_dialog| from its ConstrainedDialog
37 // and hides it from the user. 38 // and hides it from the user.
38 void OwnPrintPreviewDialog(content::WebContents* preview_dialog); 39 void OwnPrintPreviewDialog(content::WebContents* preview_dialog);
39 40
40 // Returns true if |printing_contents_set_| contains |preview_dialog|. 41 // Returns true if |printing_contents_map_| contains |preview_dialog|.
41 bool HasPrintPreviewDialog(content::WebContents* preview_dialog); 42 bool HasPrintPreviewDialog(content::WebContents* preview_dialog);
42 43
43 // Let others iterate over the list of background printing contents. 44 // Let others see the list of background printing contents.
44 WebContentsSet::const_iterator begin(); 45 std::set<content::WebContents*> CurrentContentSet();
45 WebContentsSet::const_iterator end();
46 46
47 private: 47 private:
48 // content::NotificationObserver overrides: 48 // content::NotificationObserver overrides:
49 virtual void Observe(int type, 49 virtual void Observe(int type,
50 const content::NotificationSource& source, 50 const content::NotificationSource& source,
51 const content::NotificationDetails& details) OVERRIDE; 51 const content::NotificationDetails& details) OVERRIDE;
52 52
53 // Notifications handlers. 53 // Schedule deletion of |preview_contents|.
54 void OnRendererProcessClosed(content::RenderProcessHost* rph);
55 void OnPrintJobReleased(content::WebContents* preview_contents);
56 void OnWebContentsDestroyed(content::WebContents* preview_contents);
57
58 // Add |preview_contents| to the pending deletion set and schedule deletion.
59 void DeletePreviewContents(content::WebContents* preview_contents); 54 void DeletePreviewContents(content::WebContents* preview_contents);
60 55
61 // Check if any of the WebContentses in |set| share a RenderProcessHost 56 // A map from print preview WebContentses (managed by
62 // with |tab|, excluding |tab|. 57 // BackgroundPrintingManager) to the Observers that observe them.
63 bool HasSharedRenderProcessHost(const WebContentsSet& set, 58 WebContentsObserverMap printing_contents_map_;
64 content::WebContents* preview_contents);
65
66 // The set of print preview WebContentses managed by
67 // BackgroundPrintingManager.
68 WebContentsSet printing_contents_set_;
69
70 // The set of print preview Webcontents managed by BackgroundPrintingManager
71 // that are pending deletion.
72 WebContentsSet printing_contents_pending_deletion_set_;
73 59
74 content::NotificationRegistrar registrar_; 60 content::NotificationRegistrar registrar_;
75 61
76 DISALLOW_COPY_AND_ASSIGN(BackgroundPrintingManager); 62 DISALLOW_COPY_AND_ASSIGN(BackgroundPrintingManager);
77 }; 63 };
78 64
79 } // namespace printing 65 } // namespace printing
80 66
81 #endif // CHROME_BROWSER_PRINTING_BACKGROUND_PRINTING_MANAGER_H_ 67 #endif // CHROME_BROWSER_PRINTING_BACKGROUND_PRINTING_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/printing/background_printing_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698