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

Side by Side Diff: chrome/browser/download/save_page_browsertest.cc

Issue 1395103003: Don't use base::MessageLoop::{Quit,QuitClosure} in chrome/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
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 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 waiting_ = true; 89 waiting_ = true;
90 content::RunMessageLoop(); 90 content::RunMessageLoop();
91 waiting_ = false; 91 waiting_ = false;
92 return persisted_; 92 return persisted_;
93 } 93 }
94 94
95 void OnDownloadStored(DownloadItem* item, 95 void OnDownloadStored(DownloadItem* item,
96 const history::DownloadRow& info) override { 96 const history::DownloadRow& info) override {
97 persisted_ = persisted_ || filter_.Run(item, info); 97 persisted_ = persisted_ || filter_.Run(item, info);
98 if (persisted_ && waiting_) 98 if (persisted_ && waiting_)
99 base::MessageLoopForUI::current()->Quit(); 99 base::MessageLoopForUI::current()->QuitWhenIdle();
100 } 100 }
101 101
102 private: 102 private:
103 Profile* profile_; 103 Profile* profile_;
104 PersistedFilter filter_; 104 PersistedFilter filter_;
105 bool waiting_; 105 bool waiting_;
106 bool persisted_; 106 bool persisted_;
107 107
108 DISALLOW_COPY_AND_ASSIGN(DownloadPersistedObserver); 108 DISALLOW_COPY_AND_ASSIGN(DownloadPersistedObserver);
109 }; 109 };
(...skipping 17 matching lines...) Expand all
127 waiting_ = false; 127 waiting_ = false;
128 return removed_; 128 return removed_;
129 } 129 }
130 130
131 void OnDownloadStored(DownloadItem* item, 131 void OnDownloadStored(DownloadItem* item,
132 const history::DownloadRow& info) override {} 132 const history::DownloadRow& info) override {}
133 133
134 void OnDownloadsRemoved(const DownloadHistory::IdSet& ids) override { 134 void OnDownloadsRemoved(const DownloadHistory::IdSet& ids) override {
135 removed_ = ids.find(download_id_) != ids.end(); 135 removed_ = ids.find(download_id_) != ids.end();
136 if (removed_ && waiting_) 136 if (removed_ && waiting_)
137 base::MessageLoopForUI::current()->Quit(); 137 base::MessageLoopForUI::current()->QuitWhenIdle();
138 } 138 }
139 139
140 private: 140 private:
141 bool removed_; 141 bool removed_;
142 bool waiting_; 142 bool waiting_;
143 int32 download_id_; 143 int32 download_id_;
144 144
145 DISALLOW_COPY_AND_ASSIGN(DownloadRemovedObserver); 145 DISALLOW_COPY_AND_ASSIGN(DownloadRemovedObserver);
146 }; 146 };
147 147
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } 223 }
224 224
225 private: 225 private:
226 // DownloadManager::Observer 226 // DownloadManager::Observer
227 void OnDownloadCreated(DownloadManager* manager, 227 void OnDownloadCreated(DownloadManager* manager,
228 DownloadItem* item) override { 228 DownloadItem* item) override {
229 DCHECK_EQ(manager, manager_); 229 DCHECK_EQ(manager, manager_);
230 items_seen_.push_back(item); 230 items_seen_.push_back(item);
231 231
232 if (waiting_) 232 if (waiting_)
233 base::MessageLoopForUI::current()->Quit(); 233 base::MessageLoopForUI::current()->QuitWhenIdle();
234 } 234 }
235 235
236 void ManagerGoingDown(DownloadManager* manager) override { 236 void ManagerGoingDown(DownloadManager* manager) override {
237 manager_->RemoveObserver(this); 237 manager_->RemoveObserver(this);
238 manager_ = NULL; 238 manager_ = NULL;
239 if (waiting_) 239 if (waiting_)
240 base::MessageLoopForUI::current()->Quit(); 240 base::MessageLoopForUI::current()->QuitWhenIdle();
241 } 241 }
242 242
243 bool waiting_; 243 bool waiting_;
244 DownloadManager* manager_; 244 DownloadManager* manager_;
245 std::vector<DownloadItem*> items_seen_; 245 std::vector<DownloadItem*> items_seen_;
246 246
247 DISALLOW_COPY_AND_ASSIGN(DownloadItemCreatedObserver); 247 DISALLOW_COPY_AND_ASSIGN(DownloadItemCreatedObserver);
248 }; 248 };
249 249
250 class SavePackageFinishedObserver : public content::DownloadManager::Observer { 250 class SavePackageFinishedObserver : public content::DownloadManager::Observer {
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 ASSERT_TRUE(base::ReadFileToString(full_file_name, &main_contents)); 866 ASSERT_TRUE(base::ReadFileToString(full_file_name, &main_contents));
867 EXPECT_THAT(main_contents, 867 EXPECT_THAT(main_contents,
868 HasSubstr("<iframe src=\"./iframes_files/a.html\"></iframe>")); 868 HasSubstr("<iframe src=\"./iframes_files/a.html\"></iframe>"));
869 EXPECT_THAT(main_contents, 869 EXPECT_THAT(main_contents,
870 HasSubstr("<iframe src=\"./iframes_files/b.html\"></iframe>")); 870 HasSubstr("<iframe src=\"./iframes_files/b.html\"></iframe>"));
871 EXPECT_THAT(main_contents, 871 EXPECT_THAT(main_contents,
872 HasSubstr("<img src=\"./iframes_files/1.png\">")); 872 HasSubstr("<img src=\"./iframes_files/1.png\">"));
873 } 873 }
874 874
875 } // namespace 875 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/download/download_browsertest.cc ('k') | chrome/browser/extensions/activity_log/activity_log_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698