-
Notifications
You must be signed in to change notification settings - Fork 892
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7bb1de4
commit 0f2c732
Showing
30 changed files
with
870 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* Copyright (c) 2021 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/browser/debounce/debounce_service_factory.h" | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
#include "base/memory/singleton.h" | ||
#include "brave/browser/brave_browser_process.h" | ||
#include "brave/components/debounce/browser/debounce_service.h" | ||
#include "brave/components/debounce/browser/debounce_service_impl.h" | ||
#include "components/keyed_service/content/browser_context_dependency_manager.h" | ||
#include "components/keyed_service/core/keyed_service.h" | ||
|
||
namespace debounce { | ||
|
||
// static | ||
DebounceServiceFactory* DebounceServiceFactory::GetInstance() { | ||
return base::Singleton<DebounceServiceFactory>::get(); | ||
} | ||
|
||
DebounceService* DebounceServiceFactory::GetForBrowserContext( | ||
content::BrowserContext* context) { | ||
return static_cast<DebounceService*>( | ||
GetInstance()->GetServiceForBrowserContext(context, true)); | ||
} | ||
|
||
DebounceServiceFactory::DebounceServiceFactory() | ||
: BrowserContextKeyedServiceFactory( | ||
"DebounceService", | ||
BrowserContextDependencyManager::GetInstance()) {} | ||
|
||
DebounceServiceFactory::~DebounceServiceFactory() = default; | ||
|
||
KeyedService* DebounceServiceFactory::BuildServiceInstanceFor( | ||
content::BrowserContext* context) const { | ||
debounce::DebounceDownloadService* download_service = nullptr; | ||
// Brave browser process may be null if we are being created within a unit | ||
// test. | ||
if (g_brave_browser_process) | ||
download_service = g_brave_browser_process->debounce_download_service(); | ||
std::unique_ptr<DebounceServiceImpl> debounce_service( | ||
new DebounceServiceImpl(download_service)); | ||
return debounce_service.release(); | ||
} | ||
|
||
bool DebounceServiceFactory::ServiceIsNULLWhileTesting() const { | ||
return false; | ||
} | ||
|
||
} // namespace debounce |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* Copyright (c) 2021 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_BROWSER_DEBOUNCE_DEBOUNCE_SERVICE_FACTORY_H_ | ||
#define BRAVE_BROWSER_DEBOUNCE_DEBOUNCE_SERVICE_FACTORY_H_ | ||
|
||
#include "base/macros.h" | ||
#include "base/memory/singleton.h" | ||
#include "components/keyed_service/content/browser_context_keyed_service_factory.h" | ||
|
||
class Profile; | ||
|
||
namespace debounce { | ||
|
||
class DebounceService; | ||
|
||
class DebounceServiceFactory : public BrowserContextKeyedServiceFactory { | ||
public: | ||
static DebounceService* GetForBrowserContext( | ||
content::BrowserContext* context); | ||
static DebounceServiceFactory* GetInstance(); | ||
|
||
private: | ||
friend struct base::DefaultSingletonTraits<DebounceServiceFactory>; | ||
|
||
DebounceServiceFactory(); | ||
~DebounceServiceFactory() override; | ||
|
||
// BrowserContextKeyedServiceFactory: | ||
KeyedService* BuildServiceInstanceFor( | ||
content::BrowserContext* context) const override; | ||
bool ServiceIsNULLWhileTesting() const override; | ||
|
||
DebounceServiceFactory(const DebounceServiceFactory&) = delete; | ||
DebounceServiceFactory& operator=(const DebounceServiceFactory&) = delete; | ||
}; | ||
|
||
} // namespace debounce | ||
|
||
#endif // BRAVE_BROWSER_DEBOUNCE_DEBOUNCE_SERVICE_FACTORY_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
brave_browser_debounce_sources = [ | ||
"//brave/browser/debounce/debounce_service_factory.cc", | ||
"//brave/browser/debounce/debounce_service_factory.h", | ||
] | ||
|
||
brave_browser_debounce_deps = [ | ||
"//base", | ||
"//brave/components/debounce/browser", | ||
"//brave/components/debounce/common", | ||
"//brave/extensions:common", | ||
"//chrome/common", | ||
"//components/keyed_service/content", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.