| OLD | NEW |
| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/extensions/extension_service_test_base.h" | 10 #include "chrome/browser/extensions/extension_service_test_base.h" |
| 11 #include "chrome/browser/extensions/test_extension_system.h" | 11 #include "chrome/browser/extensions/test_extension_system.h" |
| 12 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
| 13 #include "content/public/test/test_browser_thread_bundle.h" | 13 #include "content/public/test/test_browser_thread_bundle.h" |
| 14 #include "extensions/browser/extension_registry.h" |
| 14 #include "extensions/browser/process_manager.h" | 15 #include "extensions/browser/process_manager.h" |
| 15 #include "extensions/common/extension.h" | 16 #include "extensions/common/extension.h" |
| 16 #include "extensions/common/extension_builder.h" | 17 #include "extensions/common/extension_builder.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 19 |
| 19 namespace extensions { | 20 namespace extensions { |
| 20 | 21 |
| 21 // A ProcessManager that doesn't create background host pages. | 22 // A ProcessManager that doesn't create background host pages. |
| 22 class TestProcessManager : public ProcessManager { | 23 class TestProcessManager : public ProcessManager { |
| 23 public: | 24 public: |
| 24 explicit TestProcessManager(Profile* profile) | 25 explicit TestProcessManager(Profile* profile) |
| 25 : ProcessManager(profile, profile->GetOriginalProfile()), | 26 : ProcessManager(profile, |
| 27 profile->GetOriginalProfile(), |
| 28 ExtensionRegistry::Get(profile)), |
| 26 create_count_(0) {} | 29 create_count_(0) {} |
| 27 virtual ~TestProcessManager() {} | 30 virtual ~TestProcessManager() {} |
| 28 | 31 |
| 29 int create_count() { return create_count_; } | 32 int create_count() { return create_count_; } |
| 30 | 33 |
| 31 // ProcessManager overrides: | 34 // ProcessManager overrides: |
| 32 virtual bool CreateBackgroundHost(const Extension* extension, | 35 virtual bool CreateBackgroundHost(const Extension* extension, |
| 33 const GURL& url) OVERRIDE { | 36 const GURL& url) OVERRIDE { |
| 34 // Don't actually try to create a web contents. | 37 // Don't actually try to create a web contents. |
| 35 create_count_++; | 38 create_count_++; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 EXPECT_EQ(1u, queue.extensions_with_pending_tasks()); | 189 EXPECT_EQ(1u, queue.extensions_with_pending_tasks()); |
| 187 | 190 |
| 188 // Processing tasks when there is one pending runs the task and removes the | 191 // Processing tasks when there is one pending runs the task and removes the |
| 189 // extension from the list of extensions with pending tasks. | 192 // extension from the list of extensions with pending tasks. |
| 190 queue.ProcessPendingTasks(NULL, profile_.get(), extension); | 193 queue.ProcessPendingTasks(NULL, profile_.get(), extension); |
| 191 EXPECT_EQ(1, task_run_count()); | 194 EXPECT_EQ(1, task_run_count()); |
| 192 EXPECT_EQ(0u, queue.extensions_with_pending_tasks()); | 195 EXPECT_EQ(0u, queue.extensions_with_pending_tasks()); |
| 193 } | 196 } |
| 194 | 197 |
| 195 } // namespace extensions | 198 } // namespace extensions |
| OLD | NEW |