Add --ignore-connections-limit switch
This commit is contained in:
parent
cb6fba94fc
commit
ca021d030f
2 changed files with 33 additions and 0 deletions
|
@ -4,11 +4,30 @@
|
|||
|
||||
#include "browser/network_delegate.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/strings/string_split.h"
|
||||
#include "net/base/load_flags.h"
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/url_request/url_request.h"
|
||||
|
||||
namespace brightray {
|
||||
|
||||
namespace {
|
||||
|
||||
// Ignore the limit of 6 connections per host.
|
||||
const char kIgnoreConnectionsLimit[] = "ignore-connections-limit";
|
||||
|
||||
} // namespace
|
||||
|
||||
NetworkDelegate::NetworkDelegate() {
|
||||
auto command_line = base::CommandLine::ForCurrentProcess();
|
||||
if (command_line->HasSwitch(kIgnoreConnectionsLimit)) {
|
||||
std::string value = command_line->GetSwitchValueASCII(kIgnoreConnectionsLimit);
|
||||
base::SplitString(value, ',', &ignore_connections_limit_domains_);
|
||||
}
|
||||
}
|
||||
|
||||
NetworkDelegate::~NetworkDelegate() {
|
||||
|
@ -18,6 +37,15 @@ int NetworkDelegate::OnBeforeURLRequest(
|
|||
net::URLRequest* request,
|
||||
const net::CompletionCallback& callback,
|
||||
GURL* new_url) {
|
||||
for (const auto& domain : ignore_connections_limit_domains_) {
|
||||
if (request->url().DomainIs(domain.c_str(), domain.size())) {
|
||||
// Allow unlimited concurrent connections.
|
||||
request->SetPriority(net::MAXIMUM_PRIORITY);
|
||||
request->SetLoadFlags(request->load_flags() | net::LOAD_IGNORE_LIMITS);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return net::OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
#ifndef BRIGHTRAY_BROWSER_NETWORK_DELEGATE_H_
|
||||
#define BRIGHTRAY_BROWSER_NETWORK_DELEGATE_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "net/base/network_delegate.h"
|
||||
|
||||
namespace brightray {
|
||||
|
@ -69,6 +72,8 @@ class NetworkDelegate : public net::NetworkDelegate {
|
|||
const GURL& referrer_url) const override;
|
||||
|
||||
private:
|
||||
std::vector<std::string> ignore_connections_limit_domains_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(NetworkDelegate);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue