Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: net/url_request/url_request.h

Issue 6382003: Reorder the methods in net/url_request/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compiling net_unittests != compiling the rest of chrome Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/url_request/https_prober.cc ('k') | net/url_request/url_request_data_job.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_URL_REQUEST_URL_REQUEST_H_ 5 #ifndef NET_URL_REQUEST_URL_REQUEST_H_
6 #define NET_URL_REQUEST_URL_REQUEST_H_ 6 #define NET_URL_REQUEST_URL_REQUEST_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 // The lifetime of an instance of this class is completely controlled by the 51 // The lifetime of an instance of this class is completely controlled by the
52 // consumer, and the instance is not required to live on the heap or be 52 // consumer, and the instance is not required to live on the heap or be
53 // allocated in any special way. It is also valid to delete an URLRequest 53 // allocated in any special way. It is also valid to delete an URLRequest
54 // object during the handling of a callback to its delegate. Of course, once 54 // object during the handling of a callback to its delegate. Of course, once
55 // the URLRequest is deleted, no further callbacks to its delegate will occur. 55 // the URLRequest is deleted, no further callbacks to its delegate will occur.
56 // 56 //
57 // NOTE: All usage of all instances of this class should be on the same thread. 57 // NOTE: All usage of all instances of this class should be on the same thread.
58 // 58 //
59 class URLRequest : public base::NonThreadSafe { 59 class URLRequest : public base::NonThreadSafe {
60 public: 60 public:
61 // Callback function implemented by protocol handlers to create new jobs.
62 // The factory may return NULL to indicate an error, which will cause other
63 // factories to be queried. If no factory handles the request, then the
64 // default job will be used.
65 typedef URLRequestJob* (ProtocolFactory)(URLRequest* request,
66 const std::string& scheme);
67
68 // HTTP request/response header IDs (via some preprocessor fun) for use with
69 // SetRequestHeaderById and GetResponseHeaderById.
70 enum {
71 #define HTTP_ATOM(x) HTTP_ ## x,
72 #include "net/http/http_atom_list.h"
73 #undef HTTP_ATOM
74 };
75
61 // Derive from this class and add your own data members to associate extra 76 // Derive from this class and add your own data members to associate extra
62 // information with a URLRequest. Use GetUserData(key) and SetUserData() 77 // information with a URLRequest. Use GetUserData(key) and SetUserData()
63 class UserData { 78 class UserData {
64 public: 79 public:
65 UserData() {} 80 UserData() {}
66 virtual ~UserData() {} 81 virtual ~UserData() {}
67 }; 82 };
68 83
69 // Callback function implemented by protocol handlers to create new jobs.
70 // The factory may return NULL to indicate an error, which will cause other
71 // factories to be queried. If no factory handles the request, then the
72 // default job will be used.
73 typedef URLRequestJob* (ProtocolFactory)(URLRequest* request,
74 const std::string& scheme);
75
76 // This class handles network interception. Use with 84 // This class handles network interception. Use with
77 // (Un)RegisterRequestInterceptor. 85 // (Un)RegisterRequestInterceptor.
78 class Interceptor { 86 class Interceptor {
79 public: 87 public:
80 virtual ~Interceptor() {} 88 virtual ~Interceptor() {}
81 89
82 // Called for every request made. Should return a new job to handle the 90 // Called for every request made. Should return a new job to handle the
83 // request if it should be intercepted, or NULL to allow the request to 91 // request if it should be intercepted, or NULL to allow the request to
84 // be handled in the normal manner. 92 // be handled in the normal manner.
85 virtual URLRequestJob* MaybeIntercept(URLRequest* request) = 0; 93 virtual URLRequestJob* MaybeIntercept(URLRequest* request) = 0;
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 // This method can be called after the user selects a client certificate to 510 // This method can be called after the user selects a client certificate to
503 // instruct this URLRequest to continue with the request with the 511 // instruct this URLRequest to continue with the request with the
504 // certificate. Pass NULL if the user doesn't have a client certificate. 512 // certificate. Pass NULL if the user doesn't have a client certificate.
505 void ContinueWithCertificate(net::X509Certificate* client_cert); 513 void ContinueWithCertificate(net::X509Certificate* client_cert);
506 514
507 // This method can be called after some error notifications to instruct this 515 // This method can be called after some error notifications to instruct this
508 // URLRequest to ignore the current error and continue with the request. To 516 // URLRequest to ignore the current error and continue with the request. To
509 // cancel the request instead, call Cancel(). 517 // cancel the request instead, call Cancel().
510 void ContinueDespiteLastError(); 518 void ContinueDespiteLastError();
511 519
512 // HTTP request/response header IDs (via some preprocessor fun) for use with
513 // SetRequestHeaderById and GetResponseHeaderById.
514 enum {
515 #define HTTP_ATOM(x) HTTP_ ## x,
516 #include "net/http/http_atom_list.h"
517 #undef HTTP_ATOM
518 };
519
520 // Returns true if performance profiling should be enabled on the 520 // Returns true if performance profiling should be enabled on the
521 // URLRequestJob serving this request. 521 // URLRequestJob serving this request.
522 bool enable_profiling() const { return enable_profiling_; } 522 bool enable_profiling() const { return enable_profiling_; }
523 523
524 void set_enable_profiling(bool profiling) { enable_profiling_ = profiling; } 524 void set_enable_profiling(bool profiling) { enable_profiling_ = profiling; }
525 525
526 // Used to specify the context (cookie store, cache) for this request. 526 // Used to specify the context (cookie store, cache) for this request.
527 URLRequestContext* context(); 527 URLRequestContext* context();
528 void set_context(URLRequestContext* context); 528 void set_context(URLRequestContext* context);
529 529
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 // Called by URLRequestJob to allow interception when the final response 561 // Called by URLRequestJob to allow interception when the final response
562 // occurs. 562 // occurs.
563 void ResponseStarted(); 563 void ResponseStarted();
564 564
565 // Allow an interceptor's URLRequestJob to restart this request. 565 // Allow an interceptor's URLRequestJob to restart this request.
566 // Should only be called if the original job has not started a response. 566 // Should only be called if the original job has not started a response.
567 void Restart(); 567 void Restart();
568 568
569 private: 569 private:
570 friend class URLRequestJob; 570 friend class URLRequestJob;
571 typedef std::map<const void*, linked_ptr<UserData> > UserDataMap;
571 572
572 void StartJob(URLRequestJob* job); 573 void StartJob(URLRequestJob* job);
573 574
574 // Restarting involves replacing the current job with a new one such as what 575 // Restarting involves replacing the current job with a new one such as what
575 // happens when following a HTTP redirect. 576 // happens when following a HTTP redirect.
576 void RestartWithJob(URLRequestJob* job); 577 void RestartWithJob(URLRequestJob* job);
577 void PrepareToRestart(); 578 void PrepareToRestart();
578 579
579 // Detaches the job from this request in preparation for this object going 580 // Detaches the job from this request in preparation for this object going
580 // away or the job being replaced. The job will not call us back when it has 581 // away or the job being replaced. The job will not call us back when it has
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 614
614 // The HTTP response info, lazily initialized. 615 // The HTTP response info, lazily initialized.
615 net::HttpResponseInfo response_info_; 616 net::HttpResponseInfo response_info_;
616 617
617 // Tells us whether the job is outstanding. This is true from the time 618 // Tells us whether the job is outstanding. This is true from the time
618 // Start() is called to the time we dispatch RequestComplete and indicates 619 // Start() is called to the time we dispatch RequestComplete and indicates
619 // whether the job is active. 620 // whether the job is active.
620 bool is_pending_; 621 bool is_pending_;
621 622
622 // Externally-defined data accessible by key 623 // Externally-defined data accessible by key
623 typedef std::map<const void*, linked_ptr<UserData> > UserDataMap;
624 UserDataMap user_data_; 624 UserDataMap user_data_;
625 625
626 // Whether to enable performance profiling on the job serving this request. 626 // Whether to enable performance profiling on the job serving this request.
627 bool enable_profiling_; 627 bool enable_profiling_;
628 628
629 // Number of times we're willing to redirect. Used to guard against 629 // Number of times we're willing to redirect. Used to guard against
630 // infinite redirects. 630 // infinite redirects.
631 int redirect_limit_; 631 int redirect_limit_;
632 632
633 // Cached value for use after we've orphaned the job handling the 633 // Cached value for use after we've orphaned the job handling the
634 // first transaction in a request involving redirects. 634 // first transaction in a request involving redirects.
635 uint64 final_upload_progress_; 635 uint64 final_upload_progress_;
636 636
637 // The priority level for this request. Objects like ClientSocketPool use 637 // The priority level for this request. Objects like ClientSocketPool use
638 // this to determine which URLRequest to allocate sockets to first. 638 // this to determine which URLRequest to allocate sockets to first.
639 net::RequestPriority priority_; 639 net::RequestPriority priority_;
640 640
641 base::debug::LeakTracker<URLRequest> leak_tracker_; 641 base::debug::LeakTracker<URLRequest> leak_tracker_;
642 642
643 DISALLOW_COPY_AND_ASSIGN(URLRequest); 643 DISALLOW_COPY_AND_ASSIGN(URLRequest);
644 }; 644 };
645 645
646 } // namespace net 646 } // namespace net
647 647
648 #endif // NET_URL_REQUEST_URL_REQUEST_H_ 648 #endif // NET_URL_REQUEST_URL_REQUEST_H_
OLDNEW
« no previous file with comments | « net/url_request/https_prober.cc ('k') | net/url_request/url_request_data_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698