| Index: content/browser/screen_orientation/screen_orientation_service_impl.cc | 
| diff --git a/content/browser/screen_orientation/screen_orientation_service_impl.cc b/content/browser/screen_orientation/screen_orientation_service_impl.cc | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..0abb541b13e7263b3de8316b5c5eb783ec823def | 
| --- /dev/null | 
| +++ b/content/browser/screen_orientation/screen_orientation_service_impl.cc | 
| @@ -0,0 +1,64 @@ | 
| +// Copyright 2014 The Chromium Authors. All rights reserved. | 
| +// Use of this source code is governed by a BSD-style license that can be | 
| +// found in the LICENSE file. | 
| + | 
| +#include "content/browser/screen_orientation/screen_orientation_service_impl.h" | 
| + | 
| +#include "base/bind.h" | 
| +#include "content/public/browser/screen_orientation_provider.h" | 
| + | 
| +namespace content { | 
| + | 
| +// static | 
| +void ScreenOrientationServiceImpl::Create( | 
| +    ScreenOrientationProvider* provider, | 
| +    mojo::InterfaceRequest<ScreenOrientationService> request) { | 
| +  BindToRequest(new ScreenOrientationServiceImpl(provider), &request); | 
| +} | 
| + | 
| +ScreenOrientationServiceImpl::ScreenOrientationServiceImpl( | 
| +    ScreenOrientationProvider* provider) | 
| +    : provider_(provider), | 
| +      weak_factory_(this) { | 
| +} | 
| + | 
| +ScreenOrientationServiceImpl::~ScreenOrientationServiceImpl() { | 
| +} | 
| + | 
| +void ScreenOrientationServiceImpl::NotifyLockResult( | 
| +    ScreenOrientationLockResult result) { | 
| +  if (on_result_callback_.is_null()) | 
| +    return; | 
| + | 
| +  on_result_callback_.Run(result); | 
| + | 
| +  // Reset the callback. | 
| +  on_result_callback_ = mojo::Callback<void(ScreenOrientationLockResult)>(); | 
| +} | 
| + | 
| +void ScreenOrientationServiceImpl::LockOrientation( | 
| +    ScreenOrientationLockType lock_type, | 
| +    const mojo::Callback<void(ScreenOrientationLockResult)>& callback) { | 
| +  DCHECK(on_result_callback_.is_null()); | 
| +  on_result_callback_ = callback; | 
| + | 
| +  if (!provider_) { | 
| +    NotifyLockResult(SCREEN_ORIENTATION_LOCK_RESULT_ERROR_NOT_AVAILABLE); | 
| +    return; | 
| +  } | 
| + | 
| +  provider_->LockOrientation( | 
| +      lock_type, | 
| +      base::Bind(&ScreenOrientationServiceImpl::NotifyLockResult, | 
| +                 weak_factory_.GetWeakPtr())); | 
| +} | 
| + | 
| +void ScreenOrientationServiceImpl::UnlockOrientation() { | 
| +  // Cancel any pending lock request. | 
| +  NotifyLockResult(SCREEN_ORIENTATION_LOCK_RESULT_ERROR_CANCELED); | 
| + | 
| +  if (provider_) | 
| +    provider_->UnlockOrientation(); | 
| +} | 
| + | 
| +}  // namespace content | 
|  |