Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: ppapi/example/example.cc

Issue 9381010: Convert resources to take an instance key instead of an Instance*. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: USELESS PATCH TITLE Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/cpp/websocket.cc ('k') | ppapi/examples/video_capture/video_capture.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <math.h> 5 #include <math.h>
6 #include <stdio.h> // FIXME(brettw) erase me. 6 #include <stdio.h> // FIXME(brettw) erase me.
7 #ifndef _WIN32 7 #ifndef _WIN32
8 #include <sys/time.h> 8 #include <sys/time.h>
9 #else 9 #else
10 #include <windows.h> 10 #include <windows.h>
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 public: 91 public:
92 virtual void DidFetch(bool success, const std::string& data) = 0; 92 virtual void DidFetch(bool success, const std::string& data) = 0;
93 }; 93 };
94 94
95 class MyFetcher { 95 class MyFetcher {
96 public: 96 public:
97 MyFetcher() : client_(NULL) { 97 MyFetcher() : client_(NULL) {
98 callback_factory_.Initialize(this); 98 callback_factory_.Initialize(this);
99 } 99 }
100 100
101 void Start(const pp::InstancePrivate& instance, 101 void Start(pp::Instance* instance,
102 const pp::Var& url, 102 const pp::Var& url,
103 MyFetcherClient* client) { 103 MyFetcherClient* client) {
104 pp::URLRequestInfo request; 104 pp::URLRequestInfo request;
105 request.SetURL(url); 105 request.SetURL(url);
106 request.SetMethod("GET"); 106 request.SetMethod("GET");
107 107
108 loader_ = pp::URLLoader(instance); 108 loader_ = pp::URLLoader(pp::InstanceHandle(instance));
109 client_ = client; 109 client_ = client;
110 110
111 pp::CompletionCallback callback = 111 pp::CompletionCallback callback =
112 callback_factory_.NewOptionalCallback(&MyFetcher::DidOpen); 112 callback_factory_.NewOptionalCallback(&MyFetcher::DidOpen);
113 int rv = loader_.Open(request, callback); 113 int rv = loader_.Open(request, callback);
114 if (rv != PP_OK_COMPLETIONPENDING) 114 if (rv != PP_OK_COMPLETIONPENDING)
115 callback.Run(rv); 115 callback.Run(rv);
116 } 116 }
117 117
118 void StartWithOpenedLoader(const pp::URLLoader& loader, 118 void StartWithOpenedLoader(const pp::URLLoader& loader,
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 std::vector<pp::Var> props; 408 std::vector<pp::Var> props;
409 window.GetAllPropertyNames(&props); 409 window.GetAllPropertyNames(&props);
410 for (size_t i = 0; i < props.size(); ++i) 410 for (size_t i = 0; i < props.size(); ++i)
411 Log(PP_LOGLEVEL_LOG, props[i]); 411 Log(PP_LOGLEVEL_LOG, props[i]);
412 412
413 pp::VarPrivate location = window.GetProperty("location"); 413 pp::VarPrivate location = window.GetProperty("location");
414 pp::VarPrivate href = location.GetProperty("href"); 414 pp::VarPrivate href = location.GetProperty("href");
415 415
416 if (!fetcher_) { 416 if (!fetcher_) {
417 fetcher_ = new MyFetcher(); 417 fetcher_ = new MyFetcher();
418 fetcher_->Start(*this, href, this); 418 fetcher_->Start(this, href, this);
419 } 419 }
420 } 420 }
421 421
422 void DidFetch(bool success, const std::string& data) { 422 void DidFetch(bool success, const std::string& data) {
423 Log(PP_LOGLEVEL_LOG, "Downloaded location.href:"); 423 Log(PP_LOGLEVEL_LOG, "Downloaded location.href:");
424 if (success) { 424 if (success) {
425 Log(PP_LOGLEVEL_LOG, data); 425 Log(PP_LOGLEVEL_LOG, data);
426 } else { 426 } else {
427 Log(PP_LOGLEVEL_ERROR, "Failed to download."); 427 Log(PP_LOGLEVEL_ERROR, "Failed to download.");
428 } 428 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 }; 487 };
488 488
489 namespace pp { 489 namespace pp {
490 490
491 // Factory function for your specialization of the Module object. 491 // Factory function for your specialization of the Module object.
492 Module* CreateModule() { 492 Module* CreateModule() {
493 return new MyModule(); 493 return new MyModule();
494 } 494 }
495 495
496 } // namespace pp 496 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/cpp/websocket.cc ('k') | ppapi/examples/video_capture/video_capture.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698