X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fcomponents%2Fdomain_reliability%2Fmonitor.h;h=e001a4b08721be86cb1518c79fea7dfd65f6f723;hb=004985e17e624662a4c85c76a7654039dc83f028;hp=da989cd33b4732fe402273b0a080dd3467c17ffb;hpb=2f108dbacb161091e42a3479f4e171339b7e7623;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/components/domain_reliability/monitor.h b/src/components/domain_reliability/monitor.h index da989cd..e001a4b 100644 --- a/src/components/domain_reliability/monitor.h +++ b/src/components/domain_reliability/monitor.h @@ -29,54 +29,71 @@ class URLRequestContextGetter; namespace domain_reliability { -// The top-level per-profile object that measures requests and hands off the -// measurements to the proper |DomainReliabilityContext|. Referenced by the -// |ChromeNetworkDelegate|, which calls the On* methods. +// The top-level object that measures requests and hands off the measurements +// to the proper |DomainReliabilityContext|. Lives on the I/O thread, so the +// constructor accepts a URLRequestContext directly instead of a +// URLRequestContextGetter. class DOMAIN_RELIABILITY_EXPORT DomainReliabilityMonitor { public: - // NB: We don't take a URLRequestContextGetter because we already live on the - // I/O thread. - explicit DomainReliabilityMonitor( - net::URLRequestContext* url_request_context); - DomainReliabilityMonitor( - net::URLRequestContext* url_request_context, - scoped_ptr time); + DomainReliabilityMonitor(net::URLRequestContext* url_request_context, + const std::string& upload_reporter_string); + DomainReliabilityMonitor(net::URLRequestContext* url_request_context, + const std::string& upload_reporter_string, + scoped_ptr time); ~DomainReliabilityMonitor(); - // Should be called from the profile's NetworkDelegate on the corresponding - // events: + // Populates the monitor with contexts that were configured at compile time. + void AddBakedInConfigs(); + + // Should be called when |request| is about to follow a redirect. Will + // examine and possibly log the redirect request. void OnBeforeRedirect(net::URLRequest* request); + + // Should be called when |request| is complete. Will examine and possibly + // log the (final) request. (|started| should be true if the request was + // actually started before it was terminated.) void OnCompleted(net::URLRequest* request, bool started); - // Creates a context for testing, adds it to the monitor, and returns a - // pointer to it. (The pointer is only valid until the MOnitor is destroyed.) DomainReliabilityContext* AddContextForTesting( scoped_ptr config); + size_t contexts_size_for_testing() const { return contexts_.size(); } + private: friend class DomainReliabilityMonitorTest; + typedef std::map ContextMap; + struct DOMAIN_RELIABILITY_EXPORT RequestInfo { RequestInfo(); - RequestInfo(const net::URLRequest& request); + explicit RequestInfo(const net::URLRequest& request); ~RequestInfo(); + bool DefinitelyReachedNetwork() const; + GURL url; net::URLRequestStatus status; int response_code; net::HostPortPair socket_address; net::LoadTimingInfo load_timing_info; bool was_cached; + int load_flags; + bool is_upload; }; + // Creates a context, adds it to the monitor, and returns a pointer to it. + // (The pointer is only valid until the Monitor is destroyed.) + DomainReliabilityContext* AddContext( + scoped_ptr config); void OnRequestLegComplete(const RequestInfo& info); scoped_ptr time_; scoped_refptr url_request_context_getter_; + const std::string upload_reporter_string_; DomainReliabilityScheduler::Params scheduler_params_; DomainReliabilityDispatcher dispatcher_; scoped_ptr uploader_; - std::map contexts_; + ContextMap contexts_; DISALLOW_COPY_AND_ASSIGN(DomainReliabilityMonitor); };