| OLD | NEW | 
|    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 "content/renderer/fetchers/resource_fetcher_impl.h" |    5 #include "content/renderer/fetchers/resource_fetcher_impl.h" | 
|    6  |    6  | 
|    7 #include <stdint.h> |    7 #include <stdint.h> | 
|    8  |    8  | 
|    9 #include "base/logging.h" |    9 #include "base/logging.h" | 
|   10 #include "base/macros.h" |   10 #include "base/macros.h" | 
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   64       return; |   64       return; | 
|   65  |   65  | 
|   66     // Take a reference to the callback as running the callback may lead to our |   66     // Take a reference to the callback as running the callback may lead to our | 
|   67     // destruction. |   67     // destruction. | 
|   68     Callback callback = callback_; |   68     Callback callback = callback_; | 
|   69     callback.Run(status_ == LOAD_FAILED ? blink::WebURLResponse() : response_, |   69     callback.Run(status_ == LOAD_FAILED ? blink::WebURLResponse() : response_, | 
|   70                  status_ == LOAD_FAILED ? std::string() : data_); |   70                  status_ == LOAD_FAILED ? std::string() : data_); | 
|   71   } |   71   } | 
|   72  |   72  | 
|   73   // WebURLLoaderClient methods: |   73   // WebURLLoaderClient methods: | 
|   74   void didReceiveResponse(blink::WebURLLoader* loader, |   74   void didReceiveResponse(const blink::WebURLResponse& response) override { | 
|   75                           const blink::WebURLResponse& response) override { |  | 
|   76     DCHECK(!completed_); |   75     DCHECK(!completed_); | 
|   77  |   76  | 
|   78     response_ = response; |   77     response_ = response; | 
|   79   } |   78   } | 
|   80   void didReceiveCachedMetadata(blink::WebURLLoader* loader, |   79   void didReceiveCachedMetadata(const char* data, int data_length) override { | 
|   81                                 const char* data, |  | 
|   82                                 int data_length) override { |  | 
|   83     DCHECK(!completed_); |   80     DCHECK(!completed_); | 
|   84     DCHECK_GT(data_length, 0); |   81     DCHECK_GT(data_length, 0); | 
|   85   } |   82   } | 
|   86   void didReceiveData(blink::WebURLLoader* loader, |   83   void didReceiveData(const char* data, | 
|   87                       const char* data, |  | 
|   88                       int data_length, |   84                       int data_length, | 
|   89                       int encoded_data_length) override { |   85                       int encoded_data_length) override { | 
|   90     DCHECK(!completed_); |   86     DCHECK(!completed_); | 
|   91     DCHECK_GT(data_length, 0); |   87     DCHECK_GT(data_length, 0); | 
|   92  |   88  | 
|   93     data_.append(data, data_length); |   89     data_.append(data, data_length); | 
|   94   } |   90   } | 
|   95   void didFinishLoading(blink::WebURLLoader* loader, |   91   void didFinishLoading(double finishTime, | 
|   96                         double finishTime, |  | 
|   97                         int64_t total_encoded_data_length, |   92                         int64_t total_encoded_data_length, | 
|   98                         int64_t total_encoded_body_length) override { |   93                         int64_t total_encoded_body_length) override { | 
|   99     DCHECK(!completed_); |   94     DCHECK(!completed_); | 
|  100  |   95  | 
|  101     OnLoadCompleteInternal(LOAD_SUCCEEDED); |   96     OnLoadCompleteInternal(LOAD_SUCCEEDED); | 
|  102   } |   97   } | 
|  103   void didFail(blink::WebURLLoader* loader, |   98   void didFail(const blink::WebURLError& error, | 
|  104                const blink::WebURLError& error, |  | 
|  105                int64_t total_encoded_data_length, |   99                int64_t total_encoded_data_length, | 
|  106                int64_t total_encoded_body_length) override { |  100                int64_t total_encoded_body_length) override { | 
|  107     OnLoadCompleteInternal(LOAD_FAILED); |  101     OnLoadCompleteInternal(LOAD_FAILED); | 
|  108   } |  102   } | 
|  109  |  103  | 
|  110  private: |  104  private: | 
|  111   ResourceFetcherImpl* parent_; |  105   ResourceFetcherImpl* parent_; | 
|  112  |  106  | 
|  113   // Set to true once the request is complete. |  107   // Set to true once the request is complete. | 
|  114   bool completed_; |  108   bool completed_; | 
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  212 void ResourceFetcherImpl::OnLoadComplete() { |  206 void ResourceFetcherImpl::OnLoadComplete() { | 
|  213   timeout_timer_.Stop(); |  207   timeout_timer_.Stop(); | 
|  214 } |  208 } | 
|  215  |  209  | 
|  216 void ResourceFetcherImpl::Cancel() { |  210 void ResourceFetcherImpl::Cancel() { | 
|  217   loader_->cancel(); |  211   loader_->cancel(); | 
|  218   client_->Cancel(); |  212   client_->Cancel(); | 
|  219 } |  213 } | 
|  220  |  214  | 
|  221 }  // namespace content |  215 }  // namespace content | 
| OLD | NEW |