OLD | NEW |
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 #include "chrome/browser/printing/background_printing_manager.h" | 5 #include "chrome/browser/printing/background_printing_manager.h" |
6 | 6 |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 // this case is hit, someone else won the race, so there is no need to | 105 // this case is hit, someone else won the race, so there is no need to |
106 // continue. <http://crbug.com/100806> | 106 // continue. <http://crbug.com/100806> |
107 return; | 107 return; |
108 } | 108 } |
109 | 109 |
110 // Stop all observation ... | 110 // Stop all observation ... |
111 registrar_.Remove(this, chrome::NOTIFICATION_PRINT_JOB_RELEASED, | 111 registrar_.Remove(this, chrome::NOTIFICATION_PRINT_JOB_RELEASED, |
112 content::Source<WebContents>(preview_contents)); | 112 content::Source<WebContents>(preview_contents)); |
113 printing_contents_map_.erase(i); | 113 printing_contents_map_.erase(i); |
114 | 114 |
115 // ... and mortally wound the contents. (Deletion immediately is not a good | 115 // ... and mortally wound the contents. Deletion immediately is not a good |
116 // idea in case this was called from RenderViewGone.) | 116 // idea in case this was triggered by |preview_contents| far up the |
| 117 // callstack. (Trace where the NOTIFICATION_PRINT_JOB_RELEASED comes from.) |
117 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, preview_contents); | 118 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, preview_contents); |
118 } | 119 } |
119 | 120 |
120 std::set<content::WebContents*> BackgroundPrintingManager::CurrentContentSet() { | 121 std::set<content::WebContents*> BackgroundPrintingManager::CurrentContentSet() { |
121 std::set<content::WebContents*> result; | 122 std::set<content::WebContents*> result; |
122 for (const auto& entry : printing_contents_map_) | 123 for (const auto& entry : printing_contents_map_) |
123 result.insert(entry.first); | 124 result.insert(entry.first); |
124 | 125 |
125 return result; | 126 return result; |
126 } | 127 } |
127 | 128 |
128 bool BackgroundPrintingManager::HasPrintPreviewDialog( | 129 bool BackgroundPrintingManager::HasPrintPreviewDialog( |
129 WebContents* preview_dialog) { | 130 WebContents* preview_dialog) { |
130 return base::ContainsKey(printing_contents_map_, preview_dialog); | 131 return base::ContainsKey(printing_contents_map_, preview_dialog); |
131 } | 132 } |
132 | 133 |
133 } // namespace printing | 134 } // namespace printing |
OLD | NEW |