Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / devtools / devtools_network_transaction_factory.cc
blob09b8ddc88a261321f8ed74d9ee4b6e1fd04fabb2
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/devtools/devtools_network_transaction_factory.h"
7 #include <set>
8 #include <string>
10 #include "chrome/browser/devtools/devtools_network_controller.h"
11 #include "chrome/browser/devtools/devtools_network_transaction.h"
12 #include "content/public/browser/service_worker_context.h"
13 #include "net/base/net_errors.h"
14 #include "net/http/http_network_layer.h"
15 #include "net/http/http_network_transaction.h"
17 DevToolsNetworkTransactionFactory::DevToolsNetworkTransactionFactory(
18 DevToolsNetworkController* controller,
19 net::HttpNetworkSession* session)
20 : controller_(controller),
21 network_layer_(new net::HttpNetworkLayer(session)) {
22 std::set<std::string> headers;
23 headers.insert(DevToolsNetworkTransaction::kDevToolsRequestInitiator);
24 headers.insert(
25 DevToolsNetworkTransaction::kDevToolsEmulateNetworkConditionsClientId);
26 content::ServiceWorkerContext::AddExcludedHeadersForFetchEvent(headers);
29 DevToolsNetworkTransactionFactory::~DevToolsNetworkTransactionFactory() {
32 int DevToolsNetworkTransactionFactory::CreateTransaction(
33 net::RequestPriority priority,
34 scoped_ptr<net::HttpTransaction>* trans) {
35 scoped_ptr<net::HttpTransaction> network_transaction;
36 int rv = network_layer_->CreateTransaction(priority, &network_transaction);
37 if (rv != net::OK) {
38 return rv;
40 trans->reset(
41 new DevToolsNetworkTransaction(controller_, network_transaction.Pass()));
42 return net::OK;
45 net::HttpCache* DevToolsNetworkTransactionFactory::GetCache() {
46 return network_layer_->GetCache();
49 net::HttpNetworkSession* DevToolsNetworkTransactionFactory::GetSession() {
50 return network_layer_->GetSession();