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 "net/url_request/url_request_simple_job.h" | 5 #include "net/url_request/url_request_simple_job.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 memcpy(buf->data(), data_.data() + data_offset_, buf_size); | 50 memcpy(buf->data(), data_.data() + data_offset_, buf_size); |
51 data_offset_ += buf_size; | 51 data_offset_ += buf_size; |
52 *bytes_read = buf_size; | 52 *bytes_read = buf_size; |
53 return true; | 53 return true; |
54 } | 54 } |
55 | 55 |
56 void URLRequestSimpleJob::StartAsync() { | 56 void URLRequestSimpleJob::StartAsync() { |
57 if (!request_) | 57 if (!request_) |
58 return; | 58 return; |
59 | 59 |
60 if (GetData(&mime_type_, &charset_, &data_)) { | 60 int result = GetData(&mime_type_, &charset_, &data_, |
61 base::Bind(&URLRequestSimpleJob::OnGetDataCompleted, | |
62 weak_factory_.GetWeakPtr())); | |
63 if (result != ERR_IO_PENDING) | |
64 OnGetDataCompleted(result); | |
65 } | |
66 | |
67 void URLRequestSimpleJob::OnGetDataCompleted(int result) { | |
68 if (result == OK) { | |
61 // Notify that the headers are complete | 69 // Notify that the headers are complete |
62 NotifyHeadersComplete(); | 70 NotifyHeadersComplete(); |
63 } else { | 71 } else { |
64 // what should the error code be? | 72 // what should the error code be? |
wtc
2012/07/11 01:08:46
Nit: add
DCHECK_EQ(result, ERR_FAILED);
| |
65 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, | 73 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, |
66 ERR_INVALID_URL)); | 74 ERR_INVALID_URL)); |
67 } | 75 } |
68 } | 76 } |
69 | 77 |
70 } // namespace net | 78 } // namespace net |
OLD | NEW |