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

Side by Side Diff: chromeos/printing/fake_printer_discoverer.cc

Issue 2466993005: [CUPS] Fix the occasional crash when switching between different dialogs. (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « chromeos/printing/fake_printer_discoverer.h ('k') | chromeos/printing/printer_discoverer.h » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chromeos/printing/fake_printer_discoverer.h" 5 #include "chromeos/printing/fake_printer_discoverer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <memory> 9 #include <memory>
10 10
(...skipping 28 matching lines...) Expand all
39 39
40 bool FakePrinterDiscoverer::StopDiscovery() { 40 bool FakePrinterDiscoverer::StopDiscovery() {
41 discovery_running_ = false; 41 discovery_running_ = false;
42 for (auto observer : observers_) 42 for (auto observer : observers_)
43 observer->OnDiscoveryStopping(); 43 observer->OnDiscoveryStopping();
44 44
45 return true; 45 return true;
46 } 46 }
47 47
48 void FakePrinterDiscoverer::AddObserver(PrinterDiscoverer::Observer* observer) { 48 void FakePrinterDiscoverer::AddObserver(PrinterDiscoverer::Observer* observer) {
49 observers_.push_back(observer); 49 auto found = std::find(observers_.begin(), observers_.end(), observer);
50 if (found == observers_.end())
51 observers_.push_back(observer);
50 } 52 }
51 53
52 void FakePrinterDiscoverer::RemoveObserver( 54 void FakePrinterDiscoverer::RemoveObserver(
53 PrinterDiscoverer::Observer* observer) { 55 PrinterDiscoverer::Observer* observer) {
54 auto found = std::find(observers_.begin(), observers_.end(), observer); 56 auto found = std::find(observers_.begin(), observers_.end(), observer);
55 if (found != observers_.end()) 57 if (found != observers_.end())
56 observers_.erase(found); 58 observers_.erase(found);
57 } 59 }
58 60
59 FakePrinterDiscoverer::FakePrinterDiscoverer() 61 FakePrinterDiscoverer::FakePrinterDiscoverer()
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 base::TimeDelta::FromMilliseconds(2000)); 98 base::TimeDelta::FromMilliseconds(2000));
97 } else { 99 } else {
98 // We're done. Notify observers. 100 // We're done. Notify observers.
99 discovery_running_ = false; 101 discovery_running_ = false;
100 for (auto observer : observers_) 102 for (auto observer : observers_)
101 observer->OnDiscoveryDone(); 103 observer->OnDiscoveryDone();
102 } 104 }
103 } 105 }
104 106
105 } // namespace chromeos 107 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/printing/fake_printer_discoverer.h ('k') | chromeos/printing/printer_discoverer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698