| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 IOS_WEB_NET_REQUEST_TRACKER_IMPL_H_ | 5 #ifndef IOS_WEB_NET_REQUEST_TRACKER_IMPL_H_ |
| 6 #define IOS_WEB_NET_REQUEST_TRACKER_IMPL_H_ | 6 #define IOS_WEB_NET_REQUEST_TRACKER_IMPL_H_ |
| 7 | 7 |
| 8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 155 |
| 156 #pragma mark Client utility methods. | 156 #pragma mark Client utility methods. |
| 157 | 157 |
| 158 // Finds the tracker given the tab ID. As calling this method involves a lock | 158 // Finds the tracker given the tab ID. As calling this method involves a lock |
| 159 // it is expected that the provider will call it only once. | 159 // it is expected that the provider will call it only once. |
| 160 // Returns a weak pointer, which should only be dereferenced on the IO thread. | 160 // Returns a weak pointer, which should only be dereferenced on the IO thread. |
| 161 // Returns NULL if no tracker exists for |request_group_id|. | 161 // Returns NULL if no tracker exists for |request_group_id|. |
| 162 static RequestTrackerImpl* GetTrackerForRequestGroupID( | 162 static RequestTrackerImpl* GetTrackerForRequestGroupID( |
| 163 NSString* request_group_id); | 163 NSString* request_group_id); |
| 164 | 164 |
| 165 // Callback from the UI to allow or deny a particular certificate. | |
| 166 void ErrorCallback(CRWSSLCarrier* carrier, bool allow); | |
| 167 | |
| 168 // Utility method for clients to post tasks to the IO thread from the UI | 165 // Utility method for clients to post tasks to the IO thread from the UI |
| 169 // thread. | 166 // thread. |
| 170 void PostIOTask(const base::Closure& task); | 167 void PostIOTask(const base::Closure& task); |
| 171 | 168 |
| 172 // Utility method for clients to post tasks to the IO thread from the IO | 169 // Utility method for clients to post tasks to the IO thread from the IO |
| 173 // thread. | 170 // thread. |
| 174 void ScheduleIOTask(const base::Closure& task); | 171 void ScheduleIOTask(const base::Closure& task); |
| 175 | 172 |
| 176 // Utility method for clients to conditionally post tasks to the UI thread | 173 // Utility method for clients to conditionally post tasks to the UI thread |
| 177 // from the IO thread. The task will not be posted if the request tracker | 174 // from the IO thread. The task will not be posted if the request tracker |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 | 295 |
| 299 // Notifies the deleate of a load completion estimate. | 296 // Notifies the deleate of a load completion estimate. |
| 300 void NotifyUpdatedProgress(float estimate); | 297 void NotifyUpdatedProgress(float estimate); |
| 301 | 298 |
| 302 // Has the delegate clear SSL certificates. | 299 // Has the delegate clear SSL certificates. |
| 303 void NotifyClearCertificates(); | 300 void NotifyClearCertificates(); |
| 304 | 301 |
| 305 // Notifies the delegate of an SSL status update. | 302 // Notifies the delegate of an SSL status update. |
| 306 void NotifyUpdatedSSLStatus(base::scoped_nsobject<CRWSSLCarrier> carrier); | 303 void NotifyUpdatedSSLStatus(base::scoped_nsobject<CRWSSLCarrier> carrier); |
| 307 | 304 |
| 308 // Calls the delegate method to present an SSL error interstitial. | |
| 309 void NotifyPresentSSLError(base::scoped_nsobject<CRWSSLCarrier> carrier, | |
| 310 bool recoverable); | |
| 311 | |
| 312 #pragma mark Internal utilities for task posting | 305 #pragma mark Internal utilities for task posting |
| 313 // Posts |task| to |thread|. Must not be called from |thread|. If |thread| is | 306 // Posts |task| to |thread|. Must not be called from |thread|. If |thread| is |
| 314 // the IO thread, silently returns if |is_closing_| is true. | 307 // the IO thread, silently returns if |is_closing_| is true. |
| 315 void PostTask(const base::Closure& task, web::WebThread::ID thread); | 308 void PostTask(const base::Closure& task, web::WebThread::ID thread); |
| 316 | 309 |
| 317 // Posts |block| to |thread|, safely passing in |caller| to |block|. | 310 // Posts |block| to |thread|, safely passing in |caller| to |block|. |
| 318 void PostBlock(id caller, void (^block)(id), web::WebThread::ID thread); | 311 void PostBlock(id caller, void (^block)(id), web::WebThread::ID thread); |
| 319 | 312 |
| 320 #pragma mark Other internal methods. | 313 #pragma mark Other internal methods. |
| 321 // Returns the current state of the page. | 314 // Returns the current state of the page. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 338 // in it. | 331 // in it. |
| 339 std::map<const void*, TrackerCounts*> counts_by_request_; | 332 std::map<const void*, TrackerCounts*> counts_by_request_; |
| 340 // A list of all the TrackerCounts, including the finished ones. | 333 // A list of all the TrackerCounts, including the finished ones. |
| 341 std::vector<std::unique_ptr<TrackerCounts>> counts_; | 334 std::vector<std::unique_ptr<TrackerCounts>> counts_; |
| 342 // The system shall never allow the page load estimate to go back. | 335 // The system shall never allow the page load estimate to go back. |
| 343 float previous_estimate_; | 336 float previous_estimate_; |
| 344 // Index of the first request to consider for building the estimation. | 337 // Index of the first request to consider for building the estimation. |
| 345 unsigned int estimate_start_index_; | 338 unsigned int estimate_start_index_; |
| 346 // How many notifications are currently queued, to avoid notifying too often. | 339 // How many notifications are currently queued, to avoid notifying too often. |
| 347 int notification_depth_; | 340 int notification_depth_; |
| 348 // The tracker containing the error currently presented to the user. | |
| 349 TrackerCounts* current_ssl_error_; | |
| 350 // Set to |YES| if the page has mixed content | 341 // Set to |YES| if the page has mixed content |
| 351 bool has_mixed_content_; | 342 bool has_mixed_content_; |
| 352 // Set to true if between TrimToURL and StopPageLoad. | 343 // Set to true if between TrimToURL and StopPageLoad. |
| 353 bool is_loading_; | 344 bool is_loading_; |
| 354 // Set to true in TrimToURL if starting a new estimate round. Set to false by | 345 // Set to true in TrimToURL if starting a new estimate round. Set to false by |
| 355 // StartRequest once the new round is started. | 346 // StartRequest once the new round is started. |
| 356 bool new_estimate_round_; | 347 bool new_estimate_round_; |
| 357 | 348 |
| 358 #pragma mark Other fields. | 349 #pragma mark Other fields. |
| 359 scoped_refptr<web::CertificatePolicyCache> policy_cache_; | 350 scoped_refptr<web::CertificatePolicyCache> policy_cache_; |
| 360 // If |true| all the requests should be static file requests, otherwise all | |
| 361 // the requests should be network requests. This is a constant initialized | |
| 362 // in the constructor and read in IO and UI threads. | |
| 363 const bool is_for_static_file_requests_; | |
| 364 | |
| 365 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | 351 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
| 366 // Current page URL, as far as we know. | 352 // Current page URL, as far as we know. |
| 367 GURL page_url_; | 353 GURL page_url_; |
| 368 // Userinfo attached to the page, passed back by the delegate. | 354 // Userinfo attached to the page, passed back by the delegate. |
| 369 base::scoped_nsobject<id> user_info_; | 355 base::scoped_nsobject<id> user_info_; |
| 370 // A tracker identifier (a simple increasing number) used to store | 356 // A tracker identifier (a simple increasing number) used to store |
| 371 // certificates. | 357 // certificates. |
| 372 int identifier_; | 358 int identifier_; |
| 373 // The string that identifies the tab this tracker serves. Used to index | 359 // The string that identifies the tab this tracker serves. Used to index |
| 374 // g_trackers. | 360 // g_trackers. |
| 375 base::scoped_nsobject<NSString> request_group_id_; | 361 base::scoped_nsobject<NSString> request_group_id_; |
| 376 // Flag to synchronize deletion and callback creation. Lives on the IO thread. | 362 // Flag to synchronize deletion and callback creation. Lives on the IO thread. |
| 377 // True when this tracker has beed Close()d. If this is the case, no further | 363 // True when this tracker has beed Close()d. If this is the case, no further |
| 378 // references to it should be generated (for example by binding it into a | 364 // references to it should be generated (for example by binding it into a |
| 379 // callback), and the expectation is that it will soon be deleted. | 365 // callback), and the expectation is that it will soon be deleted. |
| 380 bool is_closing_; | 366 bool is_closing_; |
| 381 }; | 367 }; |
| 382 | 368 |
| 383 } // namespace web | 369 } // namespace web |
| 384 | 370 |
| 385 #endif // IOS_WEB_NET_REQUEST_TRACKER_IMPL_H_ | 371 #endif // IOS_WEB_NET_REQUEST_TRACKER_IMPL_H_ |
| OLD | NEW |