Use common code to set HttpNetworkSession::Param pointers.
[chromium-blink-merge.git] / content / renderer / internal_document_state_data.cc
blobd250853982f97cae919b85f5a41a3d852750547f
1 // Copyright (c) 2013 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 "content/renderer/internal_document_state_data.h"
7 #include "content/public/renderer/document_state.h"
8 #include "third_party/WebKit/public/web/WebDataSource.h"
10 namespace content {
12 namespace {
14 // Key InternalDocumentStateData is stored under in DocumentState.
15 const char kUserDataKey[] = "InternalDocumentStateData";
19 InternalDocumentStateData::InternalDocumentStateData()
20 : http_status_code_(0),
21 is_overriding_user_agent_(false),
22 must_reset_scroll_and_scale_state_(false),
23 cache_policy_override_set_(false),
24 cache_policy_override_(blink::WebURLRequest::UseProtocolCachePolicy) {
27 // static
28 InternalDocumentStateData* InternalDocumentStateData::FromDataSource(
29 blink::WebDataSource* ds) {
30 return FromDocumentState(static_cast<DocumentState*>(ds->extraData()));
33 // static
34 InternalDocumentStateData* InternalDocumentStateData::FromDocumentState(
35 DocumentState* ds) {
36 if (!ds)
37 return NULL;
38 InternalDocumentStateData* data = static_cast<InternalDocumentStateData*>(
39 ds->GetUserData(&kUserDataKey));
40 if (!data) {
41 data = new InternalDocumentStateData;
42 ds->SetUserData(&kUserDataKey, data);
44 return data;
47 InternalDocumentStateData::~InternalDocumentStateData() {
50 } // namespace content