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

Side by Side Diff: components/dom_distiller/core/distiller_url_fetcher.cc

Issue 2375773002: Add data usage tracking for feedback uploader, crash uploader, dom distiller (Closed)
Patch Set: Change to TRACING_UPLOADER Created 4 years, 2 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
« no previous file with comments | « components/dom_distiller/core/BUILD.gn ('k') | components/feedback/BUILD.gn » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "components/dom_distiller/core/distiller_url_fetcher.h" 5 #include "components/dom_distiller/core/distiller_url_fetcher.h"
6 6
7 #include "components/data_use_measurement/core/data_use_user_data.h"
7 #include "net/http/http_status_code.h" 8 #include "net/http/http_status_code.h"
8 #include "net/url_request/url_fetcher.h" 9 #include "net/url_request/url_fetcher.h"
9 #include "net/url_request/url_fetcher_delegate.h" 10 #include "net/url_request/url_fetcher_delegate.h"
10 #include "net/url_request/url_request_context_getter.h" 11 #include "net/url_request/url_request_context_getter.h"
11 #include "net/url_request/url_request_status.h" 12 #include "net/url_request/url_request_status.h"
12 #include "url/gurl.h" 13 #include "url/gurl.h"
13 14
14 using net::URLFetcher; 15 using net::URLFetcher;
15 16
16 namespace dom_distiller { 17 namespace dom_distiller {
(...skipping 24 matching lines...) Expand all
41 callback_ = callback; 42 callback_ = callback;
42 url_fetcher_ = CreateURLFetcher(context_getter_, url); 43 url_fetcher_ = CreateURLFetcher(context_getter_, url);
43 url_fetcher_->Start(); 44 url_fetcher_->Start();
44 } 45 }
45 46
46 std::unique_ptr<URLFetcher> DistillerURLFetcher::CreateURLFetcher( 47 std::unique_ptr<URLFetcher> DistillerURLFetcher::CreateURLFetcher(
47 net::URLRequestContextGetter* context_getter, 48 net::URLRequestContextGetter* context_getter,
48 const std::string& url) { 49 const std::string& url) {
49 std::unique_ptr<net::URLFetcher> fetcher = 50 std::unique_ptr<net::URLFetcher> fetcher =
50 URLFetcher::Create(GURL(url), URLFetcher::GET, this); 51 URLFetcher::Create(GURL(url), URLFetcher::GET, this);
52 data_use_measurement::DataUseUserData::AttachToFetcher(
53 fetcher.get(), data_use_measurement::DataUseUserData::DOM_DISTILLER);
51 fetcher->SetRequestContext(context_getter); 54 fetcher->SetRequestContext(context_getter);
52 static const int kMaxRetries = 5; 55 static const int kMaxRetries = 5;
53 fetcher->SetMaxRetriesOn5xx(kMaxRetries); 56 fetcher->SetMaxRetriesOn5xx(kMaxRetries);
54 return fetcher; 57 return fetcher;
55 } 58 }
56 59
57 void DistillerURLFetcher::OnURLFetchComplete( 60 void DistillerURLFetcher::OnURLFetchComplete(
58 const URLFetcher* source) { 61 const URLFetcher* source) {
59 std::string response; 62 std::string response;
60 if (source && source->GetStatus().is_success() && 63 if (source && source->GetStatus().is_success() &&
61 source->GetResponseCode() == net::HTTP_OK) { 64 source->GetResponseCode() == net::HTTP_OK) {
62 // Only copy over the data if the request was successful. Insert 65 // Only copy over the data if the request was successful. Insert
63 // an empty string into the proto otherwise. 66 // an empty string into the proto otherwise.
64 source->GetResponseAsString(&response); 67 source->GetResponseAsString(&response);
65 } 68 }
66 callback_.Run(response); 69 callback_.Run(response);
67 } 70 }
68 71
69 } // namespace dom_distiller 72 } // namespace dom_distiller
OLDNEW
« no previous file with comments | « components/dom_distiller/core/BUILD.gn ('k') | components/feedback/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698