Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "webkit/glue/plugins/test/plugin_get_javascript_url_test.h" | 5 #include "webkit/glue/plugins/test/plugin_get_javascript_url_test.h" |
| 6 | 6 |
| 7 | |
| 8 // url for "self". | 7 // url for "self". |
| 9 #define SELF_URL "javascript:window.location+\"\"" | 8 #define SELF_URL "javascript:window.location+\"\"" |
| 10 // The identifier for the self url stream. | 9 // The identifier for the self url stream. |
| 11 #define SELF_URL_STREAM_ID 1 | 10 #define SELF_URL_STREAM_ID 1 |
| 12 | 11 |
| 13 // The identifier for the fetched url stream. | 12 // The identifier for the fetched url stream. |
| 14 #define FETCHED_URL_STREAM_ID 2 | 13 #define FETCHED_URL_STREAM_ID 2 |
| 15 | 14 |
| 16 // The maximum chunk size of stream data. | 15 // The maximum chunk size of stream data. |
| 17 #define STREAM_CHUNK 197 | 16 #define STREAM_CHUNK 197 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 31 test_started_ = true; | 30 test_started_ = true; |
| 32 } | 31 } |
| 33 return NPERR_NO_ERROR; | 32 return NPERR_NO_ERROR; |
| 34 } | 33 } |
| 35 | 34 |
| 36 NPError ExecuteGetJavascriptUrlTest::NewStream(NPMIMEType type, NPStream* stream , | 35 NPError ExecuteGetJavascriptUrlTest::NewStream(NPMIMEType type, NPStream* stream , |
| 37 NPBool seekable, uint16* stype) { | 36 NPBool seekable, uint16* stype) { |
| 38 if (stream == NULL) | 37 if (stream == NULL) |
| 39 SetError("NewStream got null stream"); | 38 SetError("NewStream got null stream"); |
| 40 | 39 |
| 41 unsigned long stream_id = PtrToUlong(stream->notifyData); | 40 unsigned long stream_id = reinterpret_cast<unsigned long>(stream->notifyData); |
|
Mark Mentovai
2008/09/16 17:53:36
Let's add:
#include "base/basictypes.h"
and:
CO
| |
| 42 switch (stream_id) { | 41 switch (stream_id) { |
| 43 case SELF_URL_STREAM_ID: | 42 case SELF_URL_STREAM_ID: |
| 44 break; | 43 break; |
| 45 default: | 44 default: |
| 46 SetError("Unexpected NewStream callback"); | 45 SetError("Unexpected NewStream callback"); |
| 47 break; | 46 break; |
| 48 } | 47 } |
| 49 return NPERR_NO_ERROR; | 48 return NPERR_NO_ERROR; |
| 50 } | 49 } |
| 51 | 50 |
| 52 int32 ExecuteGetJavascriptUrlTest::WriteReady(NPStream *stream) { | 51 int32 ExecuteGetJavascriptUrlTest::WriteReady(NPStream *stream) { |
| 53 return STREAM_CHUNK; | 52 return STREAM_CHUNK; |
| 54 } | 53 } |
| 55 | 54 |
| 56 int32 ExecuteGetJavascriptUrlTest::Write(NPStream *stream, int32 offset, int32 l en, | 55 int32 ExecuteGetJavascriptUrlTest::Write(NPStream *stream, int32 offset, int32 l en, |
| 57 void *buffer) { | 56 void *buffer) { |
| 58 if (stream == NULL) | 57 if (stream == NULL) |
| 59 SetError("Write got null stream"); | 58 SetError("Write got null stream"); |
| 60 if (len < 0 || len > STREAM_CHUNK) | 59 if (len < 0 || len > STREAM_CHUNK) |
| 61 SetError("Write got bogus stream chunk size"); | 60 SetError("Write got bogus stream chunk size"); |
| 62 | 61 |
| 63 unsigned long stream_id = PtrToUlong(stream->notifyData); | 62 unsigned long stream_id = reinterpret_cast<unsigned long>(stream->notifyData); |
| 64 switch (stream_id) { | 63 switch (stream_id) { |
| 65 case SELF_URL_STREAM_ID: | 64 case SELF_URL_STREAM_ID: |
| 66 self_url_.append(static_cast<char*>(buffer), len); | 65 self_url_.append(static_cast<char*>(buffer), len); |
| 67 break; | 66 break; |
| 68 default: | 67 default: |
| 69 SetError("Unexpected write callback"); | 68 SetError("Unexpected write callback"); |
| 70 break; | 69 break; |
| 71 } | 70 } |
| 72 // Pretend that we took all the data. | 71 // Pretend that we took all the data. |
| 73 return len; | 72 return len; |
| 74 } | 73 } |
| 75 | 74 |
| 76 | 75 |
| 77 NPError ExecuteGetJavascriptUrlTest::DestroyStream(NPStream *stream, NPError rea son) { | 76 NPError ExecuteGetJavascriptUrlTest::DestroyStream(NPStream *stream, NPError rea son) { |
| 78 if (stream == NULL) | 77 if (stream == NULL) |
| 79 SetError("NewStream got null stream"); | 78 SetError("NewStream got null stream"); |
| 80 | 79 |
| 81 unsigned long stream_id = PtrToUlong(stream->notifyData); | 80 unsigned long stream_id = reinterpret_cast<unsigned long>(stream->notifyData); |
| 82 switch (stream_id) { | 81 switch (stream_id) { |
| 83 case SELF_URL_STREAM_ID: | 82 case SELF_URL_STREAM_ID: |
| 84 // don't care | 83 // don't care |
| 85 break; | 84 break; |
| 86 default: | 85 default: |
| 87 SetError("Unexpected NewStream callback"); | 86 SetError("Unexpected NewStream callback"); |
| 88 break; | 87 break; |
| 89 } | 88 } |
| 90 return NPERR_NO_ERROR; | 89 return NPERR_NO_ERROR; |
| 91 } | 90 } |
| 92 | 91 |
| 93 void ExecuteGetJavascriptUrlTest::URLNotify(const char* url, NPReason reason, vo id* data) { | 92 void ExecuteGetJavascriptUrlTest::URLNotify(const char* url, NPReason reason, vo id* data) { |
| 94 unsigned long stream_id = PtrToUlong(data); | 93 unsigned long stream_id = reinterpret_cast<unsigned long>(data); |
| 95 switch (stream_id) { | 94 switch (stream_id) { |
| 96 case SELF_URL_STREAM_ID: | 95 case SELF_URL_STREAM_ID: |
| 97 if (strcmp(url, SELF_URL) != 0) | 96 if (strcmp(url, SELF_URL) != 0) |
| 98 SetError("URLNotify reported incorrect url for SELF_URL"); | 97 SetError("URLNotify reported incorrect url for SELF_URL"); |
| 99 if (self_url_.empty()) | 98 if (self_url_.empty()) |
| 100 SetError("Failed to obtain window location."); | 99 SetError("Failed to obtain window location."); |
| 101 SignalTestCompleted(); | 100 SignalTestCompleted(); |
| 102 break; | 101 break; |
| 103 default: | 102 default: |
| 104 SetError("Unexpected NewStream callback"); | 103 SetError("Unexpected NewStream callback"); |
| 105 break; | 104 break; |
| 106 } | 105 } |
| 107 } | 106 } |
| 108 | 107 |
| 109 } // namespace NPAPIClient | 108 } // namespace NPAPIClient |
| 110 | 109 |
| OLD | NEW |