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

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

Issue 1284993005: Notify NetworkDelegate when bytes have been received over the network. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed tbansal and bengr comments Created 5 years, 4 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
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 #ifndef NET_URL_REQUEST_URL_REQUEST_JOB_H_ 5 #ifndef NET_URL_REQUEST_URL_REQUEST_JOB_H_
6 #define NET_URL_REQUEST_URL_REQUEST_JOB_H_ 6 #define NET_URL_REQUEST_URL_REQUEST_JOB_H_
7 7
8 #include <stdint.h>
tbansal1 2015/08/18 00:49:49 nit: I believe the preference is to separate .h fr
sclittle 2015/08/18 18:06:16 Done.
8 #include <string> 9 #include <string>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
14 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
15 #include "base/power_monitor/power_observer.h" 16 #include "base/power_monitor/power_observer.h"
16 #include "net/base/host_port_pair.h" 17 #include "net/base/host_port_pair.h"
17 #include "net/base/load_states.h" 18 #include "net/base/load_states.h"
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 void SetProxyServer(const HostPortPair& proxy_server); 347 void SetProxyServer(const HostPortPair& proxy_server);
347 348
348 // The number of bytes read before passing to the filter. This value reflects 349 // The number of bytes read before passing to the filter. This value reflects
349 // bytes read even when there is no filter. 350 // bytes read even when there is no filter.
350 int64 prefilter_bytes_read() const { return prefilter_bytes_read_; } 351 int64 prefilter_bytes_read() const { return prefilter_bytes_read_; }
351 352
352 // The number of bytes read after passing through the filter. This value 353 // The number of bytes read after passing through the filter. This value
353 // reflects bytes read even when there is no filter. 354 // reflects bytes read even when there is no filter.
354 int64 postfilter_bytes_read() const { return postfilter_bytes_read_; } 355 int64 postfilter_bytes_read() const { return postfilter_bytes_read_; }
355 356
357 // Notify the network delegate that more bytes have been received over the
358 // network, if bytes have been received since the previous notification.
359 // TODO(sclittle): Have this method also notify about sent bytes once
360 // URLRequestJob::GetTotalSentBytes has been implemented (crbug.com/518897).
361 void MaybeNotifyNetworkBytes();
362
356 // The request that initiated this job. This value MAY BE NULL if the 363 // The request that initiated this job. This value MAY BE NULL if the
357 // request was released by DetachRequest(). 364 // request was released by DetachRequest().
358 URLRequest* request_; 365 URLRequest* request_;
359 366
360 private: 367 private:
361 // When data filtering is enabled, this function is used to read data 368 // When data filtering is enabled, this function is used to read data
362 // for the filter. Returns true if raw data was read. Returns false if 369 // for the filter. Returns true if raw data was read. Returns false if
363 // an error occurred (or we are waiting for IO to complete). 370 // an error occurred (or we are waiting for IO to complete).
364 bool ReadRawDataForFilter(int *bytes_read); 371 bool ReadRawDataForFilter(int *bytes_read);
365 372
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 434
428 // Expected content size 435 // Expected content size
429 int64 expected_content_size_; 436 int64 expected_content_size_;
430 437
431 // Set when a redirect is deferred. 438 // Set when a redirect is deferred.
432 RedirectInfo deferred_redirect_info_; 439 RedirectInfo deferred_redirect_info_;
433 440
434 // The network delegate to use with this request, if any. 441 // The network delegate to use with this request, if any.
435 NetworkDelegate* network_delegate_; 442 NetworkDelegate* network_delegate_;
436 443
444 // The value from GetTotalReceivedBytes() the last time
445 // MaybeNotifyNetworkBytes() was called. Used to calculate how bytes have been
446 // newly received since the last notification.
447 int64_t last_notified_total_received_bytes_;
448
437 base::WeakPtrFactory<URLRequestJob> weak_factory_; 449 base::WeakPtrFactory<URLRequestJob> weak_factory_;
438 450
439 DISALLOW_COPY_AND_ASSIGN(URLRequestJob); 451 DISALLOW_COPY_AND_ASSIGN(URLRequestJob);
440 }; 452 };
441 453
442 } // namespace net 454 } // namespace net
443 455
444 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_H_ 456 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698