| 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 #include "extensions/renderer/request_sender.h" | 5 #include "extensions/renderer/request_sender.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "content/public/renderer/render_frame.h" | 8 #include "content/public/renderer/render_frame.h" |
| 9 #include "extensions/common/extension_messages.h" | 9 #include "extensions/common/extension_messages.h" |
| 10 #include "extensions/renderer/dispatcher.h" | |
| 11 #include "extensions/renderer/script_context.h" | 10 #include "extensions/renderer/script_context.h" |
| 12 #include "third_party/WebKit/public/web/WebDocument.h" | 11 #include "third_party/WebKit/public/web/WebDocument.h" |
| 13 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 12 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 14 #include "third_party/WebKit/public/web/WebScopedUserGesture.h" | 13 #include "third_party/WebKit/public/web/WebScopedUserGesture.h" |
| 15 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" | 14 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
| 16 #include "third_party/WebKit/public/web/WebUserGestureToken.h" | 15 #include "third_party/WebKit/public/web/WebUserGestureToken.h" |
| 17 | 16 |
| 18 namespace extensions { | 17 namespace extensions { |
| 19 | 18 |
| 20 // Contains info relevant to a pending API request. | 19 // Contains info relevant to a pending API request. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 36 tab_id_(tab_id), | 35 tab_id_(tab_id), |
| 37 previous_tab_id_(request_sender->source_tab_id_) { | 36 previous_tab_id_(request_sender->source_tab_id_) { |
| 38 request_sender_->source_tab_id_ = tab_id; | 37 request_sender_->source_tab_id_ = tab_id; |
| 39 } | 38 } |
| 40 | 39 |
| 41 RequestSender::ScopedTabID::~ScopedTabID() { | 40 RequestSender::ScopedTabID::~ScopedTabID() { |
| 42 DCHECK_EQ(tab_id_, request_sender_->source_tab_id_); | 41 DCHECK_EQ(tab_id_, request_sender_->source_tab_id_); |
| 43 request_sender_->source_tab_id_ = previous_tab_id_; | 42 request_sender_->source_tab_id_ = previous_tab_id_; |
| 44 } | 43 } |
| 45 | 44 |
| 46 RequestSender::RequestSender(Dispatcher* dispatcher) | 45 RequestSender::RequestSender() : source_tab_id_(-1) {} |
| 47 : dispatcher_(dispatcher), source_tab_id_(-1) {} | |
| 48 | 46 |
| 49 RequestSender::~RequestSender() {} | 47 RequestSender::~RequestSender() {} |
| 50 | 48 |
| 51 void RequestSender::InsertRequest(int request_id, | 49 void RequestSender::InsertRequest(int request_id, |
| 52 PendingRequest* pending_request) { | 50 PendingRequest* pending_request) { |
| 53 DCHECK_EQ(0u, pending_requests_.count(request_id)); | 51 DCHECK_EQ(0u, pending_requests_.count(request_id)); |
| 54 pending_requests_[request_id].reset(pending_request); | 52 pending_requests_[request_id].reset(pending_request); |
| 55 } | 53 } |
| 56 | 54 |
| 57 linked_ptr<PendingRequest> RequestSender::RemoveRequest(int request_id) { | 55 linked_ptr<PendingRequest> RequestSender::RemoveRequest(int request_id) { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 for (PendingRequestMap::iterator it = pending_requests_.begin(); | 132 for (PendingRequestMap::iterator it = pending_requests_.begin(); |
| 135 it != pending_requests_.end();) { | 133 it != pending_requests_.end();) { |
| 136 if (it->second->source == source) | 134 if (it->second->source == source) |
| 137 pending_requests_.erase(it++); | 135 pending_requests_.erase(it++); |
| 138 else | 136 else |
| 139 ++it; | 137 ++it; |
| 140 } | 138 } |
| 141 } | 139 } |
| 142 | 140 |
| 143 } // namespace extensions | 141 } // namespace extensions |
| OLD | NEW |