File: NetworkResourceLoadScheduler.cpp

package info (click to toggle)
webkit2gtk 2.6.2%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 115,572 kB
  • ctags: 216,388
  • sloc: cpp: 1,164,175; ansic: 18,422; perl: 16,884; python: 11,608; ruby: 9,409; xml: 8,376; asm: 4,765; yacc: 2,292; lex: 891; sh: 650; makefile: 79
file content (67 lines) | stat: -rw-r--r-- 1,891 bytes parent folder | download
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
#include "config.h"
#include "NetworkResourceLoadScheduler.h"

#include "Logging.h"
#include "NetworkConnectionToWebProcess.h"
#include "NetworkProcess.h"
#include "NetworkResourceLoadParameters.h"
#include "NetworkResourceLoader.h"
#include <wtf/MainThread.h>
#include <wtf/text/CString.h>

#if ENABLE(NETWORK_PROCESS)

using namespace WebCore;

namespace WebKit {

NetworkResourceLoadScheduler::NetworkResourceLoadScheduler()
{
    platformInitializeNetworkSettings();
}

void NetworkResourceLoadScheduler::scheduleLoader(PassRefPtr<NetworkResourceLoader> loader)
{
    ASSERT(RunLoop::isMain());

    LOG(NetworkScheduling, "(NetworkProcess) NetworkResourceLoadScheduler::scheduleLoader resource '%s'", loader->originalRequest().url().string().utf8().data());

    // This request might be from WebProcess we've lost our connection to.
    // If so we should just skip it.
    if (!loader->connectionToWebProcess())
        return;

    if (loader->connectionToWebProcess()->isSerialLoadingEnabled() && !m_activeLoaders.isEmpty()) {
        m_pendingSerialLoaders.append(loader);
        return;
    }
    m_activeLoaders.add(loader.get());

    loader->start();
}

void NetworkResourceLoadScheduler::removeLoader(NetworkResourceLoader* loader)
{
    ASSERT(RunLoop::isMain());

    LOG(NetworkScheduling, "(NetworkProcess) NetworkResourceLoadScheduler::removeLoader resource '%s'", loader->originalRequest().url().string().utf8().data());

    m_activeLoaders.remove(loader);

    while (!m_pendingSerialLoaders.isEmpty() && m_activeLoaders.isEmpty())
        scheduleLoader(m_pendingSerialLoaders.takeLast());
}

uint64_t NetworkResourceLoadScheduler::loadsPendingCount() const
{
    return m_pendingSerialLoaders.size();
}

uint64_t NetworkResourceLoadScheduler::loadsActiveCount() const
{
    return m_activeLoaders.size();
}

} // namespace WebKit

#endif // ENABLE(NETWORK_PROCESS)