-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathWebKitBrowser.cpp
More file actions
721 lines (570 loc) · 26.4 KB
/
WebKitBrowser.cpp
File metadata and controls
721 lines (570 loc) · 26.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2020 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "WebKitBrowser.h"
namespace Thunder {
namespace Plugin {
namespace {
static Metadata<WebKitBrowser> metadata(
// Version
1, 0, 0,
// Preconditions
{ subsystem::GRAPHICS },
// Terminations
{ subsystem::NOT_GRAPHICS },
// Controls
{}
);
}
/* virtual */ const string WebKitBrowser::Initialize(PluginHost::IShell* service)
{
string message;
ASSERT(service != nullptr);
ASSERT(_service == nullptr);
ASSERT(_stateController == nullptr);
ASSERT(_browser == nullptr);
ASSERT(_memory == nullptr);
ASSERT(_application == nullptr);
ASSERT(_connectionId == 0);
_service = service;
_service->AddRef();
_skipURL = _service->WebPrefix().length();
_persistentStoragePath = _service->PersistentPath();
// Register the Connection::Notification stuff. The Remote process might die before we get a
// change to "register" the sink for these events !!! So do it ahead of instantiation.
_service->Register(&_notification);
_browser = service->Root<Exchange::IWebBrowser>(_connectionId, 2000, _T("WebKitImplementation"));
if (_browser != nullptr) {
PluginHost::IStateControl* stateControl(_browser->QueryInterface<PluginHost::IStateControl>());
// We see that sometimes the WPE implementation crashes before it reaches this point, than there is
// no StateControl. Cope with this situation.
if (stateControl == nullptr) {
message = _T("WebKitBrowser StateControl could not be Obtained.");
} else {
_application = _browser->QueryInterface<Exchange::IApplication>();
if (_application != nullptr) {
RegisterAll();
_stateController = _browser->QueryInterface<PluginHost::IStateController>();
if (_stateController != nullptr) {
PluginHost::JStateController::Register(*this, _stateController);
_stateController->Register(&_notification);
}
Exchange::JWebBrowser::Register(*this, _browser);
Exchange::JWebBrowserExt::Register(*this, this);
_cookieJar = _browser->QueryInterface<Exchange::IBrowserCookieJar>();
if (_cookieJar != nullptr) {
Exchange::JBrowserCookieJar::Register(*this, _cookieJar);
}
_browserScripting = _browser->QueryInterface<Exchange::IBrowserScripting>();
if (_browserScripting) {
Exchange::JBrowserScripting::Register(*this, _browserScripting);
}
_browser->Register(&_notification);
const RPC::IRemoteConnection *connection = _service->RemoteConnection(_connectionId);
if (connection != nullptr) {
_memory = Thunder::WebKitBrowser::MemoryObserver(connection);
ASSERT(_memory != nullptr);
connection->Release();
}
if (stateControl->Configure(_service) != Core::ERROR_NONE) {
message = _T("WebKitBrowser Implementation could not be Configured.");
} else {
stateControl->Register(&_notification);
}
} else {
message = _T("WebKitBrowser Application interface could not be obtained");
}
PluginHost::ISubSystem::INotification* subsystemNotify = _browser->QueryInterface<PluginHost::ISubSystem::INotification>();
if (subsystemNotify != nullptr) {
PluginHost::ISubSystem* subsystems = _service->SubSystems();
if (subsystems != nullptr) {
subsystems->Register(subsystemNotify);
subsystems->Release();
}
subsystemNotify->Release();
}
stateControl->Release();
}
}
else {
message = _T("WebKitBrowser could not be instantiated.");
}
return message;
}
/* virtual */ void WebKitBrowser::Deinitialize(PluginHost::IShell* service VARIABLE_IS_NOT_USED)
{
if (_service != nullptr) {
ASSERT(_service == service);
// Make sure we get no longer get any notifications, we are deactivating..
_service->Unregister(&_notification);
if (_browser != nullptr) {
PluginHost::ISubSystem::INotification* subsystemNotify = _browser->QueryInterface<PluginHost::ISubSystem::INotification>();
if (subsystemNotify != nullptr) {
PluginHost::ISubSystem* subsystems = _service->SubSystems();
if (subsystems != nullptr) {
subsystems->Unregister(subsystemNotify);
subsystems->Release();
}
subsystemNotify->Release();
}
PluginHost::IStateControl* stateControl(_browser->QueryInterface<PluginHost::IStateControl>());
// In case WPE rpcprocess crashed, there is no access to the statecontrol interface, check it !!
if (stateControl != nullptr) {
stateControl->Unregister(&_notification);
stateControl->Release();
}
if (_memory != nullptr) {
_memory->Release();
_memory = nullptr;
}
if (_application != nullptr) {
if (_cookieJar != nullptr) {
Exchange::JBrowserCookieJar::Unregister(*this);
_cookieJar->Release();
_cookieJar = nullptr;
}
if (_browserScripting != nullptr) {
Exchange::JBrowserScripting::Unregister(*this);
_browserScripting->Release();
_browserScripting = nullptr;
}
Exchange::JWebBrowserExt::Unregister(*this);
Exchange::JWebBrowser::Unregister(*this);
if (_stateController != nullptr) {
PluginHost::JStateController::Unregister(*this);
_stateController->Release();
_stateController = nullptr;
}
UnregisterAll();
_browser->Unregister(&_notification);
_application->Release();
_application = nullptr;
}
RPC::IRemoteConnection* connection(_service->RemoteConnection(_connectionId));
// Stop processing of the browser:
VARIABLE_IS_NOT_USED uint32_t result = _browser->Release();
_browser = nullptr;
// It should have been the last reference we are releasing,
// so it should end up in a DESCRUCTION_SUCCEEDED, if not we
// are leaking...
ASSERT(result == Core::ERROR_DESTRUCTION_SUCCEEDED);
// If this was running in a (container) process...
if (connection != nullptr) {
// Lets trigger a cleanup sequence for
// out-of-process code. Which will guard
// that unwilling processes, get shot if
// not stopped friendly :~)
connection->Terminate();
connection->Release();
}
}
_service->Release();
_service = nullptr;
_connectionId = 0;
}
}
/* virtual */ string WebKitBrowser::Information() const
{
// No additional info to report.
return { };
}
/* virtual */ void WebKitBrowser::Inbound(Web::Request& request)
{
if (request.Verb == Web::Request::HTTP_POST) {
request.Body(_jsonBodyDataFactory.Element());
}
}
/* virtual */ Core::ProxyType<Web::Response> WebKitBrowser::Process(const Web::Request& request)
{
ASSERT(_skipURL <= request.Path.length());
TRACE(Trace::Information, (string(_T("Received request"))));
Core::ProxyType<Web::Response> result(PluginHost::IFactories::Instance().Response());
Core::TextSegmentIterator index(
Core::TextFragment(request.Path, _skipURL, request.Path.length() - _skipURL), false, '/');
result->ErrorCode = Web::STATUS_BAD_REQUEST;
result->Message = "Unknown error";
if (_browser != nullptr) {
PluginHost::IStateControl* stateControl(_browser->QueryInterface<PluginHost::IStateControl>());
ASSERT(stateControl != nullptr);
ASSERT(_application != nullptr);
if (request.Verb == Web::Request::HTTP_GET) {
bool visible = false;
static_cast<const Thunder::Exchange::IApplication*>(_application)->Visible(visible);
PluginHost::IStateControl::state currentState = stateControl->State();
Core::ProxyType<Web::JSONBodyType<WebKitBrowser::Data>> body(_jsonBodyDataFactory.Element());
ASSERT(body.IsValid() == true);
string url;
static_cast<const Thunder::Exchange::IWebBrowser*>(_browser)->URL(url);
body->URL = url;
uint8_t fps = 0;
_browser->FPS(fps);
body->FPS = fps;
body->Suspended = (currentState == PluginHost::IStateControl::SUSPENDED);
body->Hidden = !visible;
result->ErrorCode = Web::STATUS_OK;
result->Message = "OK";
result->Body<Web::JSONBodyType<WebKitBrowser::Data>>(body);
} else if ((request.Verb == Web::Request::HTTP_POST) && (index.Next() == true) && (index.Next() == true)) {
result->ErrorCode = Web::STATUS_OK;
result->Message = "OK";
// We might be receiving a plugin download request.
if (index.Remainder() == _T("Suspend")) {
stateControl->Request(PluginHost::IStateControl::SUSPEND);
} else if (index.Remainder() == _T("Resume")) {
stateControl->Request(PluginHost::IStateControl::RESUME);
} else if (index.Remainder() == _T("Hide")) {
_browser->Visibility(Exchange::IWebBrowser::VisibilityType::HIDDEN);
} else if (index.Remainder() == _T("Show")) {
_browser->Visibility(Exchange::IWebBrowser::VisibilityType::VISIBLE);
} else if ((index.Remainder() == _T("URL")) && (request.HasBody() == true) && (request.Body<const Data>()->URL.Value().empty() == false)) {
const string url = request.Body<const Data>()->URL.Value();
_browser->URL(url);
} else if ((index.Remainder() == _T("Delete")) && (request.HasBody() == true) && (request.Body<const Data>()->Path.Value().empty() == false)) {
if (DeleteDir(request.Body<const Data>()->Path.Value()) != Core::ERROR_NONE) {
result->ErrorCode = Web::STATUS_BAD_REQUEST;
result->Message = "Unknown error";
}
} else {
result->ErrorCode = Web::STATUS_BAD_REQUEST;
result->Message = "Unknown error";
}
}
stateControl->Release();
}
return result;
}
Core::hresult WebKitBrowser::DeleteDir(const string& path)
{
Core::hresult result = Core::ERROR_NONE;
if (path.empty() == false) {
string fullPath = _persistentStoragePath + Core::Directory::Normalize(path, true);
Core::Directory dir(fullPath.c_str());
dir.Destroy();
}
else {
result = Core::ERROR_UNKNOWN_KEY;
}
return (result);
}
Core::hresult WebKitBrowser::Languages(Exchange::IWebBrowserExt::IStringIterator*& languages) const
{
ASSERT(_application != nullptr);
string languagesList;
static_cast<const Exchange::IApplication*>(_application)->Language(languagesList);
Core::JSON::ArrayType<Core::JSON::String> array;
array.FromString(languagesList);
std::list<string> list;
auto iterator = array.Elements();
while (iterator.Next() == true) {
list.push_back(iterator.Current().Value());
}
languages = Core::ServiceType<RPC::IteratorType<RPC::IStringIterator>>::Create<RPC::IStringIterator>(list);
return (Core::ERROR_NONE);
}
Core::hresult WebKitBrowser::Languages(Exchange::IWebBrowserExt::IStringIterator* const languages)
{
ASSERT(_application != nullptr);
Core::JSON::ArrayType<Core::JSON::String> array;
string entry;
while (languages->Next(entry) == true) {
array.Add() = entry;
}
_application->Language(static_cast<const string>(Core::ToString(array)));
return (Core::ERROR_NONE);
}
void WebKitBrowser::LoadFinished(const string& URL, int32_t code)
{
ASSERT(_service != nullptr);
string message(string("{ \"url\": \"") + URL + string("\", \"loaded\":true, \"httpstatus\":") + Core::NumberType<int32_t>(code).Text() + string(" }"));
TRACE(Trace::Information, (_T("LoadFinished: %s"), message.c_str()));
_service->Notify(message);
Exchange::JWebBrowser::Event::LoadFinished(*this, URL, code);
URLChange(URL, true);
}
void WebKitBrowser::LoadFailed(const string& URL)
{
ASSERT(_service != nullptr);
string message(string("{ \"url\": \"") + URL + string("\" }"));
TRACE(Trace::Information, (_T("LoadFailed: %s"), message.c_str()));
_service->Notify(message);
Exchange::JWebBrowser::Event::LoadFailed(*this, URL);
}
void WebKitBrowser::URLChange(const string& URL, bool loaded)
{
ASSERT(_service != nullptr);
string message(string("{ \"url\": \"") + URL + string("\", \"loaded\": ") + (loaded ? string("true") : string("false")) + string(" }"));
TRACE(Trace::Information, (_T("URLChanged: %s"), message.c_str()));
_service->Notify(message);
Exchange::JWebBrowser::Event::URLChange(*this, URL, loaded);
}
void WebKitBrowser::VisibilityChange(const bool hidden)
{
ASSERT(_service != nullptr);
TRACE(Trace::Information, (_T("VisibilityChange: { \"hidden\": \"%s\"}"), (hidden ? "true" : "false")));
string message(string("{ \"hidden\": ") + (hidden ? _T("true") : _T("false")) + string("}"));
_service->Notify(message);
Exchange::JWebBrowser::Event::VisibilityChange(*this, hidden);
}
void WebKitBrowser::PageClosure()
{
ASSERT(_service != nullptr);
TRACE(Trace::Information, (_T("Closure: \"true\"")));
_service->Notify(_T("{\"Closure\": true }"));
Exchange::JWebBrowser::Event::PageClosure(*this);
}
void WebKitBrowser::BridgeQuery(const string& message)
{
Exchange::JWebBrowser::Event::BridgeQuery(*this, message);
}
void WebKitBrowser::CookieJarChanged()
{
Exchange::JBrowserCookieJar::Event::CookieJarChanged(*this);
}
void WebKitBrowser::StateChange(const PluginHost::IStateControl::state state)
{
ASSERT(_service != nullptr);
TRACE(Trace::Information, (_T("StateChange: { \"State\": %d }"), state));
string message(string("{ \"suspended\": ") + (state == PluginHost::IStateControl::SUSPENDED ? _T("true") : _T("false")) + string(" }"));
_service->Notify(message);
event_statechange(state == PluginHost::IStateControl::SUSPENDED);
}
void WebKitBrowser::StateChanged(const PluginHost::IStateController::state state)
{
PluginHost::JStateController::Event::StateChanged(*this, state);
}
void WebKitBrowser::Deactivated(RPC::IRemoteConnection* connection)
{
ASSERT(_service != nullptr);
ASSERT(connection != nullptr);
if (connection->Id() == _connectionId) {
ASSERT(_service != nullptr);
Core::IWorkerPool::Instance().Submit(PluginHost::IShell::Job::Create(_service, PluginHost::IShell::DEACTIVATED, PluginHost::IShell::FAILURE));
}
}
} // namespace Plugin
namespace WebKitBrowser {
// TODO: maybe nice to expose this in the config.json
static const TCHAR* mandatoryProcesses[] = {
_T("WPENetworkProcess"),
_T("WPEWebProcess")
};
class ProcessMemoryObserverImpl : public Exchange::IProcessMemory {
public:
explicit ProcessMemoryObserverImpl(pid_t id)
: Exchange::IProcessMemory()
, _info(id)
{
}
~ProcessMemoryObserverImpl() override = default;
ProcessMemoryObserverImpl(const ProcessMemoryObserverImpl&) = delete;
ProcessMemoryObserverImpl& operator=(const ProcessMemoryObserverImpl&) = delete;
uint64_t Resident() const override {
return _info.Resident();
}
uint64_t Allocated() const override {
return _info.Allocated();
}
uint64_t Shared() const override {
return _info.Shared();
}
uint8_t Processes() const override {
return 0; // webkit and network process do now spawn mew children
}
bool IsOperational() const override {
return _info.IsActive();
}
uint32_t Identifier() const override {
return _info.Id();
}
string Name() const override {
return _info.Name();
}
BEGIN_INTERFACE_MAP(ProcessMemoryObserverImpl)
INTERFACE_ENTRY(Exchange::IProcessMemory)
END_INTERFACE_MAP
private:
Core::ProcessInfo _info;
};
static constexpr uint16_t RequiredChildren = (sizeof(mandatoryProcesses) / sizeof(mandatoryProcesses[0]));
using SteadyClock = std::chrono::steady_clock;
using TimePoint = std::chrono::time_point<SteadyClock>;
class MemoryObserverImpl : public Exchange::IMemory, public Exchange::IMemoryExtended {
private:
enum { TYPICAL_STARTUP_TIME = 10 }; /* in Seconds */
public:
MemoryObserverImpl(const RPC::IRemoteConnection* connection)
: _main(connection == nullptr ? Core::ProcessInfo().Id() : connection->RemoteId())
, _children(_main.Id())
, _startTime(connection == nullptr ? (TimePoint::min()) : (SteadyClock::now() + std::chrono::seconds(TYPICAL_STARTUP_TIME)))
, _adminLock()
{
}
~MemoryObserverImpl() override = default;
MemoryObserverImpl(const MemoryObserverImpl&) = delete;
MemoryObserverImpl& operator=(const MemoryObserverImpl&) = delete;
uint64_t Resident() const override
{
uint32_t result(0);
if (_startTime != TimePoint::min()) {
_adminLock.Lock();
if (_children.Count() < RequiredChildren) {
_children = Core::ProcessInfo::Iterator(_main.Id());
}
Core::ProcessInfo::Iterator children(_children);
_adminLock.Unlock();
result = _main.Resident();
children.Reset();
while (children.Next() == true) {
result += children.Current().Resident();
}
}
return (result);
}
uint64_t Allocated() const override
{
uint32_t result(0);
if (_startTime != TimePoint::min()) {
_adminLock.Lock();
if (_children.Count() < RequiredChildren) {
_children = Core::ProcessInfo::Iterator(_main.Id());
}
Core::ProcessInfo::Iterator children(_children);
_adminLock.Unlock();
result = _main.Allocated();
children.Reset();
while (children.Next() == true) {
result += children.Current().Allocated();
}
}
return (result);
}
uint64_t Shared() const override
{
uint32_t result(0);
if (_startTime != TimePoint::min()) {
_adminLock.Lock();
if (_children.Count() < RequiredChildren) {
_children = Core::ProcessInfo::Iterator(_main.Id());
}
Core::ProcessInfo::Iterator children(_children);
_adminLock.Unlock();
result = _main.Shared();
children.Reset();
while (children.Next() == true) {
result += children.Current().Shared();
}
}
return (result);
}
uint8_t Processes() const override
{
// Refresh the children list !!!
_adminLock.Lock();
_children = Core::ProcessInfo::Iterator(_main.Id());
uint32_t nbrchildren = _children.Count();
_adminLock.Unlock();
return ((_startTime == TimePoint::min()) || (_main.IsActive() == true) ? 1 : 0) + nbrchildren;
}
bool IsOperational() const override
{
uint32_t requiredProcesses = 0;
if (_startTime != TimePoint::min()) {
//!< We can monitor a max of 32 processes, every mandatory process represents a bit in the requiredProcesses.
// In the end we check if all bits are 0, what means all mandatory processes are still running.
requiredProcesses = (0xFFFFFFFF >> (32 - RequiredChildren));
_adminLock.Lock();
if (_children.Count() < RequiredChildren) {
// Refresh the children list !!!
_children = Core::ProcessInfo::Iterator(_main.Id());
}
Core::ProcessInfo::Iterator children(_children);
_adminLock.Unlock();
//!< If there are less children than in the the mandatoryProcesses struct, we are done and return false.
if (children.Count() >= RequiredChildren) {
children.Reset();
//!< loop over all child processes as long as we are operational.
while ((requiredProcesses != 0) && (true == children.Next())) {
uint8_t count(0);
string name(children.Current().Name());
while ((count < RequiredChildren) && (name != mandatoryProcesses[count])) {
++count;
}
//<! this is a mandatory process and if its still active reset its bit in requiredProcesses.
// If not we are not completely operational.
if ((count < RequiredChildren) && (children.Current().IsActive() == true)) {
requiredProcesses &= (~(1 << count));
}
}
}
}
return (((requiredProcesses == 0) || (true == IsStarting())) && (true == _main.IsActive()));
}
uint32_t Processes(RPC::IStringIterator*& processnames) const override {
_adminLock.Lock();
if (_children.Count() < RequiredChildren) {
// Refresh the children list !!!
_children = Core::ProcessInfo::Iterator(_main.Id());
}
Core::ProcessInfo::Iterator children(_children);
_adminLock.Unlock();
std::list<string> processes;
children.Reset();
while (children.Next() == true) {
processes.push_back(children.Current().Name());
}
processnames = Core::ServiceType<RPC::StringIterator>::Create<RPC::IStringIterator>(processes);
return Core::ERROR_NONE;
}
uint32_t Process(const string& processname, Exchange::IProcessMemory*& process) const override {
uint32_t result = Core::ERROR_UNAVAILABLE;
process = nullptr;
_adminLock.Lock();
Core::ProcessInfo::Iterator children(_children);
_adminLock.Unlock();
children.Reset();
while (children.Next() == true ) {
if (children.Current().Name() == processname ) {
process = Core::ServiceType<ProcessMemoryObserverImpl>::Create<Exchange::IProcessMemory>(children.Current().Id());
result = Core::ERROR_NONE;
break;
}
}
return result;
}
BEGIN_INTERFACE_MAP(MemoryObserverImpl)
INTERFACE_ENTRY(Exchange::IMemory)
INTERFACE_ENTRY(Exchange::IMemoryExtended)
END_INTERFACE_MAP
private:
inline bool IsStarting() const
{
return (_startTime == TimePoint::min()) || (SteadyClock::now() < _startTime);
}
private:
Core::ProcessInfo _main;
mutable Core::ProcessInfo::Iterator _children;
TimePoint _startTime; // !< Reference for monitor
mutable Core::CriticalSection _adminLock; // note IMemory could be used from multiple threads (plugins)!!
};
Exchange::IMemory* MemoryObserver(const RPC::IRemoteConnection* connection)
{
Exchange::IMemory* result = Core::ServiceType<MemoryObserverImpl>::Create<Exchange::IMemory>(connection);
return (result);
}
} // namespace WebKitBrowser
} // Thunder