summaryrefslogtreecommitdiffstats
path: root/net/url_request/url_request_view_net_internals_job.h
blob: 3d1eff3909a48f8318cb996b3ba7c5e877baf2c5 (plain)
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
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef NET_URL_REQUEST_URL_REQUEST_VIEW_NET_INTERNALS_JOB_H_
#define NET_URL_REQUEST_URL_REQUEST_VIEW_NET_INTERNALS_JOB_H_

#include "net/url_request/url_request.h"
#include "net/url_request/url_request_simple_job.h"

// A job subclass that implements a protocol to inspect the internal
// state of the network stack. The exact format of the URLs is left up to
// the caller, and is described by a URLFormat instance passed into
// the constructor.
class URLRequestViewNetInternalsJob : public URLRequestSimpleJob {
 public:
  class URLFormat;

  // |url_format| must remain valid for the duration |this|'s lifespan.
  URLRequestViewNetInternalsJob(URLRequest* request,
                                URLFormat* url_format)
      : URLRequestSimpleJob(request), url_format_(url_format) {}

  // URLRequestSimpleJob methods:
  virtual bool GetData(std::string* mime_type,
                       std::string* charset,
                       std::string* data) const;

  // Overridden methods from URLRequestJob:
  virtual bool IsRedirectResponse(GURL* location, int* http_status_code);

 private:
  ~URLRequestViewNetInternalsJob() {}

  // Returns true if the current request is for a "view-cache" URL.
  // If it is, then |key| is assigned the particular cache URL of the request.
  bool GetViewCacheKeyForRequest(std::string* key) const;

  URLFormat* url_format_;
};

// Describes how to pack/unpack the filter string (details)
// from a URL.
class URLRequestViewNetInternalsJob::URLFormat {
 public:
  virtual ~URLFormat() {}
  virtual std::string GetDetails(const GURL& url) = 0;
  virtual GURL MakeURL(const std::string& details) = 0;
};

#endif  // NET_URL_REQUEST_URL_REQUEST_VIEW_NET_INTERNALS_JOB_H_