• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2009 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 #ifndef NET_URL_REQUEST_URL_REQUEST_VIEW_NET_INTERNALS_JOB_H_
6 #define NET_URL_REQUEST_URL_REQUEST_VIEW_NET_INTERNALS_JOB_H_
7 
8 #include "net/url_request/url_request.h"
9 #include "net/url_request/url_request_simple_job.h"
10 
11 // A job subclass that implements a protocol to inspect the internal
12 // state of the network stack. The exact format of the URLs is left up to
13 // the caller, and is described by a URLFormat instance passed into
14 // the constructor.
15 class URLRequestViewNetInternalsJob : public URLRequestSimpleJob {
16  public:
17   class URLFormat;
18 
19   // |url_format| must remain valid for the duration |this|'s lifespan.
URLRequestViewNetInternalsJob(URLRequest * request,URLFormat * url_format)20   URLRequestViewNetInternalsJob(URLRequest* request,
21                                 URLFormat* url_format)
22       : URLRequestSimpleJob(request), url_format_(url_format) {}
23 
24   // URLRequestSimpleJob methods:
25   virtual bool GetData(std::string* mime_type,
26                        std::string* charset,
27                        std::string* data) const;
28 
29   // Overridden methods from URLRequestJob:
30   virtual bool IsRedirectResponse(GURL* location, int* http_status_code);
31 
32  private:
~URLRequestViewNetInternalsJob()33   ~URLRequestViewNetInternalsJob() {}
34 
35   // Returns true if the current request is for a "view-cache" URL.
36   // If it is, then |key| is assigned the particular cache URL of the request.
37   bool GetViewCacheKeyForRequest(std::string* key) const;
38 
39   URLFormat* url_format_;
40 };
41 
42 // Describes how to pack/unpack the filter string (details)
43 // from a URL.
44 class URLRequestViewNetInternalsJob::URLFormat {
45  public:
~URLFormat()46   virtual ~URLFormat() {}
47   virtual std::string GetDetails(const GURL& url) = 0;
48   virtual GURL MakeURL(const std::string& details) = 0;
49 };
50 
51 #endif  // NET_URL_REQUEST_URL_REQUEST_VIEW_NET_INTERNALS_JOB_H_
52