16e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved. 26e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 36e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// found in the LICENSE file. 46e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 56e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#ifndef MOJO_SHELL_UI_APPLICATION_LOADER_ANDROID_H_ 66e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#define MOJO_SHELL_UI_APPLICATION_LOADER_ANDROID_H_ 76e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 86e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "base/memory/scoped_ptr.h" 96e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "mojo/application_manager/application_loader.h" 106e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 116e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)namespace mojo { 126e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 136e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)class ApplicationManager; 146e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 156e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)namespace shell { 166e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)class Context; 176e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)} 186e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 196e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// ApplicationLoader implementation that creates a background thread and issues 206e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// load 216e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// requests there. 226e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)class UIApplicationLoader : public ApplicationLoader { 236e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) public: 246e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) UIApplicationLoader(scoped_ptr<ApplicationLoader> real_loader, 256e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) shell::Context* context); 266e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) virtual ~UIApplicationLoader(); 276e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 286e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // ApplicationLoader overrides: 296e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) virtual void Load(ApplicationManager* manager, 306e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const GURL& url, 316e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) scoped_refptr<LoadCallbacks> callbacks) OVERRIDE; 321320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci virtual void OnApplicationError(ApplicationManager* manager, 331320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci const GURL& url) OVERRIDE; 346e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 356e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) private: 366e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) class UILoader; 376e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 386e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // These functions are exected on the background thread. They call through 396e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // to |background_loader_| to do the actual loading. 406e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // TODO: having this code take a |manager| is fragile (as ApplicationManager 416e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // isn't thread safe). 426e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) void LoadOnUIThread(ApplicationManager* manager, 436e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const GURL& url, 446e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) ScopedMessagePipeHandle* shell_handle); 451320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci void OnApplicationErrorOnUIThread(ApplicationManager* manager, 461320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci const GURL& url); 476e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) void ShutdownOnUIThread(); 486e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 496e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) scoped_ptr<ApplicationLoader> loader_; 506e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) shell::Context* context_; 516e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 526e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Lives on the UI thread. Trivial interface that calls through to |loader_|. 536e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) UILoader* ui_loader_; 546e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 556e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(UIApplicationLoader); 566e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)}; 576e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 586e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)} // namespace mojo 596e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 606e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#endif // MOJO_SHELL_UI_APPLICATION_LOADER_ANDROID_H_ 61