summaryrefslogtreecommitdiffstats
path: root/net/url_request/url_request_view_net_internals_job.h
blob: 9f23f9632a9460d16daf3ad7bec26f1de7d1a7ff (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
// 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) {}

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

 private:
  ~URLRequestViewNetInternalsJob() {}

  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_