summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorrockot <rockot@chromium.org>2015-04-13 12:24:20 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-13 19:24:43 +0000
commit076507a08729c9ad087c2abf16e1a57f3dc18478 (patch)
tree700fd3a66c4e9fecad9688f5cc908befbf917b1f /content
parent039e11b1ec1c487e24ea1747aec1aa8719b59720 (diff)
downloadchromium_src-076507a08729c9ad087c2abf16e1a57f3dc18478.zip
chromium_src-076507a08729c9ad087c2abf16e1a57f3dc18478.tar.gz
chromium_src-076507a08729c9ad087c2abf16e1a57f3dc18478.tar.bz2
Update mojo sdk to rev d459e688a608f6eda850a23bb5e308a76ea51a47
Relanding previous roll (https://codereview.chromium.org/1051303002/), now with less MSVS breakage. BUG=None TBR=jamesr@chromium.org,timvolodine@chromium.org,imcheng@chromium.org Review URL: https://codereview.chromium.org/1079403002 Cr-Commit-Position: refs/heads/master@{#324896}
Diffstat (limited to 'content')
-rw-r--r--content/browser/geolocation/geolocation_service_impl.cc8
-rw-r--r--content/browser/presentation/presentation_service_impl.cc68
-rw-r--r--content/browser/presentation/presentation_service_impl.h25
3 files changed, 71 insertions, 30 deletions
diff --git a/content/browser/geolocation/geolocation_service_impl.cc b/content/browser/geolocation/geolocation_service_impl.cc
index ffea846..7747cc4 100644
--- a/content/browser/geolocation/geolocation_service_impl.cc
+++ b/content/browser/geolocation/geolocation_service_impl.cc
@@ -69,6 +69,14 @@ GeolocationServiceImpl::GeolocationServiceImpl(
}
GeolocationServiceImpl::~GeolocationServiceImpl() {
+ // Make sure to respond to any pending callback even without a valid position.
+ if (!position_callback_.is_null()) {
+ if (!current_position_.valid) {
+ current_position_.error_code = MojoGeoposition::ErrorCode(
+ GEOPOSITION_ERROR_CODE_POSITION_UNAVAILABLE);
+ }
+ ReportCurrentPosition();
+ }
}
void GeolocationServiceImpl::PauseUpdates() {
diff --git a/content/browser/presentation/presentation_service_impl.cc b/content/browser/presentation/presentation_service_impl.cc
index 9e2fd22..2d6769e 100644
--- a/content/browser/presentation/presentation_service_impl.cc
+++ b/content/browser/presentation/presentation_service_impl.cc
@@ -25,6 +25,7 @@ PresentationServiceImpl::PresentationServiceImpl(
: WebContentsObserver(web_contents),
render_frame_host_(render_frame_host),
delegate_(delegate),
+ is_start_session_pending_(false),
next_request_session_id_(0),
weak_factory_(this) {
DCHECK(render_frame_host_);
@@ -39,6 +40,7 @@ PresentationServiceImpl::PresentationServiceImpl(
PresentationServiceImpl::~PresentationServiceImpl() {
if (delegate_)
delegate_->RemoveObserver(this);
+ FlushNewSessionCallbacks();
}
// static
@@ -146,10 +148,13 @@ void PresentationServiceImpl::StartSession(
return;
}
- queued_start_session_requests_.push_back(make_linked_ptr(
- new StartSessionRequest(presentation_url, presentation_id, callback)));
- if (queued_start_session_requests_.size() == 1)
- DoStartSession(presentation_url, presentation_id, callback);
+ if (is_start_session_pending_) {
+ queued_start_session_requests_.push_back(make_linked_ptr(
+ new StartSessionRequest(presentation_url, presentation_id, callback)));
+ return;
+ }
+
+ DoStartSession(presentation_url, presentation_id, callback);
}
void PresentationServiceImpl::JoinSession(
@@ -175,15 +180,16 @@ void PresentationServiceImpl::JoinSession(
}
void PresentationServiceImpl::HandleQueuedStartSessionRequests() {
- DCHECK(!queued_start_session_requests_.empty());
- queued_start_session_requests_.pop_front();
- if (!queued_start_session_requests_.empty()) {
- const linked_ptr<StartSessionRequest>& request =
- queued_start_session_requests_.front();
- DoStartSession(request->presentation_url,
- request->presentation_id,
- request->callback);
+ if (queued_start_session_requests_.empty()) {
+ is_start_session_pending_ = false;
+ return;
}
+ linked_ptr<StartSessionRequest> request =
+ queued_start_session_requests_.front();
+ queued_start_session_requests_.pop_front();
+ DoStartSession(request->presentation_url(),
+ request->presentation_id(),
+ request->PassCallback());
}
int PresentationServiceImpl::RegisterNewSessionCallback(
@@ -194,11 +200,19 @@ int PresentationServiceImpl::RegisterNewSessionCallback(
return next_request_session_id_;
}
+void PresentationServiceImpl::FlushNewSessionCallbacks() {
+ for (auto& pending_entry : pending_session_cbs_) {
+ InvokeNewSessionMojoCallbackWithError(*pending_entry.second);
+ }
+ pending_session_cbs_.clear();
+}
+
void PresentationServiceImpl::DoStartSession(
const std::string& presentation_url,
const std::string& presentation_id,
const NewSessionMojoCallback& callback) {
int request_session_id = RegisterNewSessionCallback(callback);
+ is_start_session_pending_ = true;
delegate_->StartSession(
render_frame_host_->GetProcess()->GetID(),
render_frame_host_->GetRoutingID(),
@@ -361,20 +375,12 @@ void PresentationServiceImpl::Reset() {
default_presentation_url_.clear();
default_presentation_id_.clear();
- for (const auto& context_entry : availability_contexts_) {
- context_entry.second->OnScreenAvailabilityChanged(false);
- }
availability_contexts_.clear();
- for (auto& request_ptr : queued_start_session_requests_) {
- InvokeNewSessionMojoCallbackWithError(request_ptr->callback);
- }
queued_start_session_requests_.clear();
- for (auto& pending_entry : pending_session_cbs_) {
- InvokeNewSessionMojoCallbackWithError(*pending_entry.second);
- }
- pending_session_cbs_.clear();
+ FlushNewSessionCallbacks();
}
+// static
void PresentationServiceImpl::InvokeNewSessionMojoCallbackWithError(
const NewSessionMojoCallback& callback) {
callback.Run(
@@ -396,6 +402,8 @@ PresentationServiceImpl::ScreenAvailabilityContext::ScreenAvailabilityContext(
PresentationServiceImpl::ScreenAvailabilityContext::
~ScreenAvailabilityContext() {
+ // Ensure that pending callbacks are flushed.
+ OnScreenAvailabilityChanged(false);
}
void PresentationServiceImpl::ScreenAvailabilityContext::CallbackReceived(
@@ -452,12 +460,22 @@ PresentationServiceImpl::StartSessionRequest::StartSessionRequest(
const std::string& presentation_url,
const std::string& presentation_id,
const NewSessionMojoCallback& callback)
- : presentation_url(presentation_url),
- presentation_id(presentation_id),
- callback(callback) {
+ : presentation_url_(presentation_url),
+ presentation_id_(presentation_id),
+ callback_(callback) {
}
PresentationServiceImpl::StartSessionRequest::~StartSessionRequest() {
+ // Ensure that a pending callback is not dropped.
+ if (!callback_.is_null())
+ InvokeNewSessionMojoCallbackWithError(callback_);
+}
+
+PresentationServiceImpl::NewSessionMojoCallback
+PresentationServiceImpl::StartSessionRequest::PassCallback() {
+ NewSessionMojoCallback callback = callback_;
+ callback_.reset();
+ return callback;
}
} // namespace content
diff --git a/content/browser/presentation/presentation_service_impl.h b/content/browser/presentation/presentation_service_impl.h
index 5b4972d..84962e7 100644
--- a/content/browser/presentation/presentation_service_impl.h
+++ b/content/browser/presentation/presentation_service_impl.h
@@ -110,15 +110,24 @@ class CONTENT_EXPORT PresentationServiceImpl
};
// Context for a StartSession request.
- struct CONTENT_EXPORT StartSessionRequest {
+ class CONTENT_EXPORT StartSessionRequest {
+ public:
StartSessionRequest(const std::string& presentation_url,
const std::string& presentation_id,
const NewSessionMojoCallback& callback);
~StartSessionRequest();
- const std::string presentation_url;
- const std::string presentation_id;
- const NewSessionMojoCallback callback;
+ // Retrieves the pending callback from this request, transferring ownership
+ // to the caller.
+ NewSessionMojoCallback PassCallback();
+
+ const std::string& presentation_url() const { return presentation_url_; }
+ const std::string& presentation_id() const { return presentation_id_; }
+
+ private:
+ const std::string presentation_url_;
+ const std::string presentation_id_;
+ NewSessionMojoCallback callback_;
};
friend class PresentationServiceImplTest;
@@ -235,8 +244,11 @@ class CONTENT_EXPORT PresentationServiceImpl
int RegisterNewSessionCallback(
const NewSessionMojoCallback& callback);
+ // Flushes all pending new session callbacks with error responses.
+ void FlushNewSessionCallbacks();
+
// Invokes |callback| with an error.
- void InvokeNewSessionMojoCallbackWithError(
+ static void InvokeNewSessionMojoCallbackWithError(
const NewSessionMojoCallback& callback);
// Gets the ScreenAvailabilityContext for |presentation_url|, or creates one
@@ -259,6 +271,9 @@ class CONTENT_EXPORT PresentationServiceImpl
// it is removed from head of the queue.
std::deque<linked_ptr<StartSessionRequest>> queued_start_session_requests_;
+ // Indicates that a StartSession request is currently being processed.
+ bool is_start_session_pending_;
+
int next_request_session_id_;
base::hash_map<int, linked_ptr<NewSessionMojoCallback>> pending_session_cbs_;