Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/Platform.cpp

Issue 29508555: Issue 5450 - move FilterEngine into Platform (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: Created Aug. 7, 2017, 8:28 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 return; 71 return;
72 jsEngine = JsEngine::New(appInfo, *this); 72 jsEngine = JsEngine::New(appInfo, *this);
73 } 73 }
74 74
75 std::shared_ptr<JsEngine> Platform::GetJsEngine() 75 std::shared_ptr<JsEngine> Platform::GetJsEngine()
76 { 76 {
77 SetUpJsEngine(); 77 SetUpJsEngine();
78 return jsEngine; 78 return jsEngine;
79 } 79 }
80 80
81 void Platform::CreateFilterEngineAsync(const FilterEngine::CreationParameters& p arameters,
82 const OnFilterEngineCreatedCallback& onCreated)
83 {
84 std::shared_ptr<std::promise<FilterEnginePtr>> filterEnginePromise;
85 {
86 std::lock_guard<std::mutex> lock(modulesMutex);
87 if (filterEngine.valid())
88 return;
89 filterEnginePromise = std::make_shared<std::promise<FilterEnginePtr>>();
90 filterEngine = filterEnginePromise->get_future();
91 }
92
93 FilterEngine::CreateAsync(GetJsEngine(), [this, onCreated, filterEnginePromise ](const FilterEnginePtr& filterEngine)
94 {
95 filterEnginePromise->set_value(filterEngine);
96 if (onCreated)
97 onCreated(filterEngine);
98 }, parameters);
99 }
100
101 FilterEnginePtr Platform::GetFilterEngine()
102 {
103 CreateFilterEngineAsync();
104 return std::shared_future<FilterEnginePtr>(filterEngine).get();
105 }
106
81 ITimer& Platform::GetTimer() 107 ITimer& Platform::GetTimer()
82 { 108 {
83 return *timer; 109 return *timer;
84 } 110 }
85 111
86 IFileSystem& Platform::GetFileSystem() 112 IFileSystem& Platform::GetFileSystem()
87 { 113 {
88 return *fileSystem; 114 return *fileSystem;
89 } 115 }
90 116
91 IWebRequest& Platform::GetWebRequest() 117 IWebRequest& Platform::GetWebRequest()
92 { 118 {
93 return *webRequest; 119 return *webRequest;
94 } 120 }
95 121
96 LogSystem& Platform::GetLogSystem() 122 LogSystem& Platform::GetLogSystem()
97 { 123 {
98 return *logSystem; 124 return *logSystem;
99 } 125 }
OLDNEW
« no previous file with comments | « src/FilterEngine.cpp ('k') | test/BaseJsTest.h » ('j') | test/BaseJsTest.h » ('J')

Powered by Google App Engine
This is Rietveld