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

Side by Side Diff: extensions/browser/lazy_background_task_queue_unittest.cc

Issue 2802433004: ExtensionsTest: Move initialization to SetUp and avoid potential UAF. (Closed)
Patch Set: Avoid UAF. Created 3 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "extensions/browser/lazy_background_task_queue.h" 5 #include "extensions/browser/lazy_background_task_queue.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 .Build()) 107 .Build())
108 .Build()) 108 .Build())
109 .SetID("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb") 109 .SetID("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")
110 .Build(); 110 .Build();
111 ExtensionRegistry::Get(browser_context())->AddEnabled(extension); 111 ExtensionRegistry::Get(browser_context())->AddEnabled(extension);
112 return extension; 112 return extension;
113 } 113 }
114 114
115 protected: 115 protected:
116 void SetUp() override { 116 void SetUp() override {
117 ExtensionsTest::SetUp();
117 user_prefs::UserPrefs::Set(browser_context(), &testing_pref_service_); 118 user_prefs::UserPrefs::Set(browser_context(), &testing_pref_service_);
118 } 119 }
119 120
120 private: 121 private:
121 sync_preferences::TestingPrefServiceSyncable testing_pref_service_; 122 sync_preferences::TestingPrefServiceSyncable testing_pref_service_;
122 123
123 // The total number of pending tasks that have been executed. 124 // The total number of pending tasks that have been executed.
124 int task_run_count_; 125 int task_run_count_;
125 126
126 DISALLOW_COPY_AND_ASSIGN(LazyBackgroundTaskQueueTest); 127 DISALLOW_COPY_AND_ASSIGN(LazyBackgroundTaskQueueTest);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 EXPECT_EQ(1u, queue.extensions_with_pending_tasks()); 210 EXPECT_EQ(1u, queue.extensions_with_pending_tasks());
210 211
211 // Processing tasks when there is one pending runs the task and removes the 212 // Processing tasks when there is one pending runs the task and removes the
212 // extension from the list of extensions with pending tasks. 213 // extension from the list of extensions with pending tasks.
213 queue.ProcessPendingTasks(NULL, browser_context(), extension.get()); 214 queue.ProcessPendingTasks(NULL, browser_context(), extension.get());
214 EXPECT_EQ(1, task_run_count()); 215 EXPECT_EQ(1, task_run_count());
215 EXPECT_EQ(0u, queue.extensions_with_pending_tasks()); 216 EXPECT_EQ(0u, queue.extensions_with_pending_tasks());
216 } 217 }
217 218
218 } // namespace extensions 219 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698