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

Side by Side Diff: chrome/browser/net/chrome_network_delegate.cc

Issue 1459793002: Android: Allow compiling browser without Java UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/net/chrome_network_delegate.h" 5 #include "chrome/browser/net/chrome_network_delegate.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "net/base/load_flags.h" 49 #include "net/base/load_flags.h"
50 #include "net/base/net_errors.h" 50 #include "net/base/net_errors.h"
51 #include "net/cookies/canonical_cookie.h" 51 #include "net/cookies/canonical_cookie.h"
52 #include "net/cookies/cookie_options.h" 52 #include "net/cookies/cookie_options.h"
53 #include "net/http/http_request_headers.h" 53 #include "net/http/http_request_headers.h"
54 #include "net/http/http_response_headers.h" 54 #include "net/http/http_response_headers.h"
55 #include "net/http/http_status_code.h" 55 #include "net/http/http_status_code.h"
56 #include "net/log/net_log.h" 56 #include "net/log/net_log.h"
57 #include "net/url_request/url_request.h" 57 #include "net/url_request/url_request.h"
58 58
59 #if defined(OS_ANDROID) 59 #if defined(ANDROID_JAVA_UI)
Ted C 2015/11/30 19:39:05 it is really weird to see a UI ifdef in the networ
no sievers 2015/11/30 23:56:34 I debated decorating a lot of this code with TODOs
60 #include "chrome/browser/io_thread.h" 60 #include "chrome/browser/io_thread.h"
61 #include "chrome/browser/precache/precache_manager_factory.h" 61 #include "chrome/browser/precache/precache_manager_factory.h"
62 #include "components/precache/content/precache_manager.h" 62 #include "components/precache/content/precache_manager.h"
63 #endif 63 #endif
64 64
65 #if defined(OS_CHROMEOS) 65 #if defined(OS_CHROMEOS)
66 #include "base/sys_info.h" 66 #include "base/sys_info.h"
67 #include "chrome/common/chrome_switches.h" 67 #include "chrome/common/chrome_switches.h"
68 #endif 68 #endif
69 69
(...skipping 29 matching lines...) Expand all
99 void ForceGoogleSafeSearchCallbackWrapper( 99 void ForceGoogleSafeSearchCallbackWrapper(
100 const net::CompletionCallback& callback, 100 const net::CompletionCallback& callback,
101 net::URLRequest* request, 101 net::URLRequest* request,
102 GURL* new_url, 102 GURL* new_url,
103 int rv) { 103 int rv) {
104 if (rv == net::OK && new_url->is_empty()) 104 if (rv == net::OK && new_url->is_empty())
105 safe_search_util::ForceGoogleSafeSearch(request, new_url); 105 safe_search_util::ForceGoogleSafeSearch(request, new_url);
106 callback.Run(rv); 106 callback.Run(rv);
107 } 107 }
108 108
109 #if defined(OS_ANDROID) 109 #if defined(ANDROID_JAVA_UI)
110 void RecordPrecacheStatsOnUIThread(const GURL& url, 110 void RecordPrecacheStatsOnUIThread(const GURL& url,
111 const GURL& referrer, 111 const GURL& referrer,
112 base::TimeDelta latency, 112 base::TimeDelta latency,
113 const base::Time& fetch_time, 113 const base::Time& fetch_time,
114 int64 size, 114 int64 size,
115 bool was_cached, 115 bool was_cached,
116 void* profile_id) { 116 void* profile_id) {
117 DCHECK_CURRENTLY_ON(BrowserThread::UI); 117 DCHECK_CURRENTLY_ON(BrowserThread::UI);
118 118
119 if (!g_browser_process->profile_manager()->IsValidProfile(profile_id)) 119 if (!g_browser_process->profile_manager()->IsValidProfile(profile_id))
120 return; 120 return;
121 Profile* profile = reinterpret_cast<Profile*>(profile_id); 121 Profile* profile = reinterpret_cast<Profile*>(profile_id);
122 122
123 precache::PrecacheManager* precache_manager = 123 precache::PrecacheManager* precache_manager =
124 precache::PrecacheManagerFactory::GetForBrowserContext(profile); 124 precache::PrecacheManagerFactory::GetForBrowserContext(profile);
125 // |precache_manager| could be NULL if the profile is off the record. 125 // |precache_manager| could be NULL if the profile is off the record.
126 if (!precache_manager || !precache_manager->IsPrecachingAllowed()) 126 if (!precache_manager || !precache_manager->IsPrecachingAllowed())
127 return; 127 return;
128 128
129 precache_manager->RecordStatsForFetch(url, referrer, latency, fetch_time, 129 precache_manager->RecordStatsForFetch(url, referrer, latency, fetch_time,
130 size, was_cached); 130 size, was_cached);
131 } 131 }
132 #endif // defined(OS_ANDROID) 132 #endif // defined(ANDROID_JAVA_UI)
133 133
134 void ReportInvalidReferrerSendOnUI() { 134 void ReportInvalidReferrerSendOnUI() {
135 base::RecordAction( 135 base::RecordAction(
136 base::UserMetricsAction("Net.URLRequest_StartJob_InvalidReferrer")); 136 base::UserMetricsAction("Net.URLRequest_StartJob_InvalidReferrer"));
137 } 137 }
138 138
139 void ReportInvalidReferrerSend(const GURL& target_url, 139 void ReportInvalidReferrerSend(const GURL& target_url,
140 const GURL& referrer_url) { 140 const GURL& referrer_url) {
141 LOG(ERROR) << "Cancelling request to " << target_url 141 LOG(ERROR) << "Cancelling request to " << target_url
142 << " with invalid referrer " << referrer_url; 142 << " with invalid referrer " << referrer_url;
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 #endif 519 #endif
520 RecordNetworkErrorHistograms(request); 520 RecordNetworkErrorHistograms(request);
521 if (started) { 521 if (started) {
522 // Only call in for requests that were started, to obey the precondition 522 // Only call in for requests that were started, to obey the precondition
523 // that RecordCacheStateStats can only be called on requests for which 523 // that RecordCacheStateStats can only be called on requests for which
524 // OnResponseStarted was called. 524 // OnResponseStarted was called.
525 RecordCacheStateStats(request); 525 RecordCacheStateStats(request);
526 } 526 }
527 527
528 if (request->status().status() == net::URLRequestStatus::SUCCESS) { 528 if (request->status().status() == net::URLRequestStatus::SUCCESS) {
529 #if defined(OS_ANDROID) 529 #if defined(ANDROID_JAVA_UI)
530 // For better accuracy, we use the actual bytes read instead of the length 530 // For better accuracy, we use the actual bytes read instead of the length
531 // specified with the Content-Length header, which may be inaccurate, 531 // specified with the Content-Length header, which may be inaccurate,
532 // or missing, as is the case with chunked encoding. 532 // or missing, as is the case with chunked encoding.
533 int64 received_content_length = request->received_response_content_length(); 533 int64 received_content_length = request->received_response_content_length();
534 base::TimeDelta latency = base::TimeTicks::Now() - request->creation_time(); 534 base::TimeDelta latency = base::TimeTicks::Now() - request->creation_time();
535 535
536 // Record precache metrics when a fetch is completed successfully, if 536 // Record precache metrics when a fetch is completed successfully, if
537 // precaching is allowed. 537 // precaching is allowed.
538 BrowserThread::PostTask( 538 BrowserThread::PostTask(
539 BrowserThread::UI, FROM_HERE, 539 BrowserThread::UI, FROM_HERE,
540 base::Bind(&RecordPrecacheStatsOnUIThread, request->url(), 540 base::Bind(&RecordPrecacheStatsOnUIThread, request->url(),
541 GURL(request->referrer()), latency, base::Time::Now(), 541 GURL(request->referrer()), latency, base::Time::Now(),
542 received_content_length, request->was_cached(), profile_)); 542 received_content_length, request->was_cached(), profile_));
543 #endif // defined(OS_ANDROID) 543 #endif // defined(ANDROID_JAVA_UI)
544 extensions_delegate_->OnCompleted(request, started); 544 extensions_delegate_->OnCompleted(request, started);
545 } else if (request->status().status() == net::URLRequestStatus::FAILED || 545 } else if (request->status().status() == net::URLRequestStatus::FAILED ||
546 request->status().status() == net::URLRequestStatus::CANCELED) { 546 request->status().status() == net::URLRequestStatus::CANCELED) {
547 extensions_delegate_->OnCompleted(request, started); 547 extensions_delegate_->OnCompleted(request, started);
548 } else { 548 } else {
549 NOTREACHED(); 549 NOTREACHED();
550 } 550 }
551 if (domain_reliability_monitor_) 551 if (domain_reliability_monitor_)
552 domain_reliability_monitor_->OnCompleted(request, started); 552 domain_reliability_monitor_->OnCompleted(request, started);
553 RecordRequestSourceBandwidth(request, started); 553 RecordRequestSourceBandwidth(request, started);
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 if (!data_use_aggregator_) 742 if (!data_use_aggregator_)
743 return; 743 return;
744 744
745 if (is_data_usage_off_the_record_) { 745 if (is_data_usage_off_the_record_) {
746 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes); 746 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes);
747 return; 747 return;
748 } 748 }
749 749
750 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes); 750 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes);
751 } 751 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698