| 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 "chrome/browser/android/android_stream_reader_url_request_job.h" | 5 #include "chrome/browser/android/android_stream_reader_url_request_job.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "net/base/io_buffer.h" | 9 #include "net/base/io_buffer.h" |
| 10 #include "net/base/mime_util.h" | 10 #include "net/base/mime_util.h" |
| 11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
| 12 #include "net/base/net_util.h" | 12 #include "net/base/net_util.h" |
| 13 #include "net/http/http_util.h" | 13 #include "net/http/http_util.h" |
| 14 #include "net/url_request/url_request.h" | 14 #include "net/url_request/url_request.h" |
| 15 #include "net/url_request/url_request_context.h" | |
| 16 #include "net/url_request/url_request_error_job.h" | 15 #include "net/url_request/url_request_error_job.h" |
| 17 #include "net/url_request/url_request_file_job.h" | 16 #include "net/url_request/url_request_file_job.h" |
| 18 #include "net/url_request/url_request_job_manager.h" | 17 #include "net/url_request/url_request_job_manager.h" |
| 19 // Disable "Warnings treated as errors" for input_stream_jni as it's a Java | 18 // Disable "Warnings treated as errors" for input_stream_jni as it's a Java |
| 20 // system class and we have to generate C++ hooks for all methods in the class | 19 // system class and we have to generate C++ hooks for all methods in the class |
| 21 // even if they're unused. | 20 // even if they're unused. |
| 22 #pragma GCC diagnostic ignored "-Wunused-function" | 21 #pragma GCC diagnostic ignored "-Wunused-function" |
| 23 #include "jni/InputStream_jni.h" | 22 #include "jni/InputStream_jni.h" |
| 24 | 23 |
| 25 using base::android::AttachCurrentThread; | 24 using base::android::AttachCurrentThread; |
| 26 using base::android::ClearException; | 25 using base::android::ClearException; |
| 27 using base::android::ConvertUTF8ToJavaString; | 26 using base::android::ConvertUTF8ToJavaString; |
| 28 using base::android::ScopedJavaGlobalRef; | 27 using base::android::ScopedJavaGlobalRef; |
| 29 using base::android::ScopedJavaLocalRef; | 28 using base::android::ScopedJavaLocalRef; |
| 30 using JNI_InputStream::Java_InputStream_available; | 29 using JNI_InputStream::Java_InputStream_available; |
| 31 using JNI_InputStream::Java_InputStream_skip; | 30 using JNI_InputStream::Java_InputStream_skip; |
| 32 using JNI_InputStream::Java_InputStream_read; | 31 using JNI_InputStream::Java_InputStream_read; |
| 33 | 32 |
| 34 | 33 |
| 35 namespace { | 34 namespace { |
| 36 | 35 |
| 37 // Maximum number of bytes to be read in a single read. | 36 // Maximum number of bytes to be read in a single read. |
| 38 const int kBufferSize = 4096; | 37 const int kBufferSize = 4096; |
| 39 | 38 |
| 40 } // namespace | 39 } // namespace |
| 41 | 40 |
| 42 AndroidStreamReaderURLRequestJob::AndroidStreamReaderURLRequestJob( | 41 AndroidStreamReaderURLRequestJob::AndroidStreamReaderURLRequestJob( |
| 43 net::URLRequest* request, | 42 net::URLRequest* request, |
| 43 net::NetworkDelegate* network_delegate, |
| 44 scoped_ptr<Delegate> delegate) | 44 scoped_ptr<Delegate> delegate) |
| 45 : URLRequestJob(request, request->context()->network_delegate()), | 45 : URLRequestJob(request, network_delegate), |
| 46 delegate_(delegate.Pass()) { | 46 delegate_(delegate.Pass()) { |
| 47 DCHECK(delegate_.get()); | 47 DCHECK(delegate_.get()); |
| 48 } | 48 } |
| 49 | 49 |
| 50 AndroidStreamReaderURLRequestJob::~AndroidStreamReaderURLRequestJob() { | 50 AndroidStreamReaderURLRequestJob::~AndroidStreamReaderURLRequestJob() { |
| 51 } | 51 } |
| 52 | 52 |
| 53 bool AndroidStreamReaderURLRequestJob::InitJNIBindings(JNIEnv* env) { | 53 bool AndroidStreamReaderURLRequestJob::InitJNIBindings(JNIEnv* env) { |
| 54 return JNI_InputStream::RegisterNativesImpl(env); | 54 return JNI_InputStream::RegisterNativesImpl(env); |
| 55 } | 55 } |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 } else { | 219 } else { |
| 220 // We don't support multiple range requests in one single URL request, | 220 // We don't support multiple range requests in one single URL request, |
| 221 // because we need to do multipart encoding here. | 221 // because we need to do multipart encoding here. |
| 222 NotifyDone(net::URLRequestStatus( | 222 NotifyDone(net::URLRequestStatus( |
| 223 net::URLRequestStatus::FAILED, | 223 net::URLRequestStatus::FAILED, |
| 224 net::ERR_REQUEST_RANGE_NOT_SATISFIABLE)); | 224 net::ERR_REQUEST_RANGE_NOT_SATISFIABLE)); |
| 225 } | 225 } |
| 226 } | 226 } |
| 227 } | 227 } |
| 228 } | 228 } |
| OLD | NEW |