| 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 "components/keyed_service/content/browser_context_dependency_manager.h" | 8 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 9 #include "content/public/browser/notification_service.h" | 9 #include "content/public/browser/notification_service.h" |
| 10 #include "content/public/test/test_browser_context.h" | 10 #include "content/public/test/test_browser_context.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 create_count_(0) { | 33 create_count_(0) { |
| 34 // ProcessManager constructor above assumes non-incognito. | 34 // ProcessManager constructor above assumes non-incognito. |
| 35 DCHECK(!context->IsOffTheRecord()); | 35 DCHECK(!context->IsOffTheRecord()); |
| 36 } | 36 } |
| 37 virtual ~TestProcessManager() {} | 37 virtual ~TestProcessManager() {} |
| 38 | 38 |
| 39 int create_count() { return create_count_; } | 39 int create_count() { return create_count_; } |
| 40 | 40 |
| 41 // ProcessManager overrides: | 41 // ProcessManager overrides: |
| 42 virtual bool CreateBackgroundHost(const Extension* extension, | 42 virtual bool CreateBackgroundHost(const Extension* extension, |
| 43 const GURL& url) OVERRIDE { | 43 const GURL& url) override { |
| 44 // Don't actually try to create a web contents. | 44 // Don't actually try to create a web contents. |
| 45 create_count_++; | 45 create_count_++; |
| 46 return false; | 46 return false; |
| 47 } | 47 } |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 int create_count_; | 50 int create_count_; |
| 51 | 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(TestProcessManager); | 52 DISALLOW_COPY_AND_ASSIGN(TestProcessManager); |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 // A simple ExtensionSystem that returns a TestProcessManager. | 55 // A simple ExtensionSystem that returns a TestProcessManager. |
| 56 class MockExtensionSystemWithProcessManager : public MockExtensionSystem { | 56 class MockExtensionSystemWithProcessManager : public MockExtensionSystem { |
| 57 public: | 57 public: |
| 58 explicit MockExtensionSystemWithProcessManager(BrowserContext* context) | 58 explicit MockExtensionSystemWithProcessManager(BrowserContext* context) |
| 59 : MockExtensionSystem(context), test_process_manager_(context) {} | 59 : MockExtensionSystem(context), test_process_manager_(context) {} |
| 60 virtual ~MockExtensionSystemWithProcessManager() {} | 60 virtual ~MockExtensionSystemWithProcessManager() {} |
| 61 | 61 |
| 62 virtual ProcessManager* process_manager() OVERRIDE { | 62 virtual ProcessManager* process_manager() override { |
| 63 return &test_process_manager_; | 63 return &test_process_manager_; |
| 64 } | 64 } |
| 65 | 65 |
| 66 private: | 66 private: |
| 67 TestProcessManager test_process_manager_; | 67 TestProcessManager test_process_manager_; |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 } // namespace | 70 } // namespace |
| 71 | 71 |
| 72 // Derives from ExtensionsTest to provide content module and keyed service | 72 // Derives from ExtensionsTest to provide content module and keyed service |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 EXPECT_EQ(1u, queue.extensions_with_pending_tasks()); | 213 EXPECT_EQ(1u, queue.extensions_with_pending_tasks()); |
| 214 | 214 |
| 215 // Processing tasks when there is one pending runs the task and removes the | 215 // Processing tasks when there is one pending runs the task and removes the |
| 216 // extension from the list of extensions with pending tasks. | 216 // extension from the list of extensions with pending tasks. |
| 217 queue.ProcessPendingTasks(NULL, browser_context(), extension.get()); | 217 queue.ProcessPendingTasks(NULL, browser_context(), extension.get()); |
| 218 EXPECT_EQ(1, task_run_count()); | 218 EXPECT_EQ(1, task_run_count()); |
| 219 EXPECT_EQ(0u, queue.extensions_with_pending_tasks()); | 219 EXPECT_EQ(0u, queue.extensions_with_pending_tasks()); |
| 220 } | 220 } |
| 221 | 221 |
| 222 } // namespace extensions | 222 } // namespace extensions |
| OLD | NEW |