resource_request_details.cc revision a1401311d1ab56c4ed0a474bd38c108f75cb0cd9
1// Copyright (c) 2012 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.
4
5#include "content/public/browser/resource_request_details.h"
6
7#include "content/browser/worker_host/worker_service_impl.h"
8#include "content/public/browser/resource_request_info.h"
9#include "net/url_request/url_request.h"
10
11namespace content {
12
13ResourceRequestDetails::ResourceRequestDetails(const net::URLRequest* request,
14                                               int cert_id)
15    : url(request->url()),
16      original_url(request->original_url()),
17      method(request->method()),
18      referrer(request->referrer()),
19      has_upload(request->has_upload()),
20      load_flags(request->load_flags()),
21      status(request->status()),
22      ssl_cert_id(cert_id),
23      ssl_cert_status(request->ssl_info().cert_status),
24      socket_address(request->GetSocketAddress()) {
25  const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request);
26  resource_type = info->GetResourceType();
27  render_frame_id = info->GetRenderFrameID();
28
29  // If request is from the worker process on behalf of a renderer, use
30  // the renderer process id, since it consumes the notification response
31  // such as ssl state etc.
32  // TODO(atwilson): need to notify all associated renderers in the case
33  // of ssl state change (http://crbug.com/25357). For now, just notify
34  // the first one (works for dedicated workers and shared workers with
35  // a single process).
36  int worker_render_frame_id;
37  if (!WorkerServiceImpl::GetInstance()->GetRendererForWorker(
38          info->GetChildID(), &origin_child_id, &worker_render_frame_id)) {
39    origin_child_id = info->GetChildID();
40  }
41}
42
43ResourceRequestDetails::~ResourceRequestDetails() {}
44
45ResourceRedirectDetails::ResourceRedirectDetails(const net::URLRequest* request,
46                                                 int cert_id,
47                                                 const GURL& new_url)
48    : ResourceRequestDetails(request, cert_id),
49      new_url(new_url) {
50}
51
52ResourceRedirectDetails::~ResourceRedirectDetails() {}
53
54}  // namespace content
55